Support for legacy multiply options in config files. #7
This commit is contained in:
parent
0b42139e54
commit
80adbb7044
1 changed files with 10 additions and 2 deletions
|
@ -143,14 +143,17 @@ our $Options = {
|
||||||
'duplicate_x' => {
|
'duplicate_x' => {
|
||||||
label => 'Copies along X',
|
label => 'Copies along X',
|
||||||
type => 'i',
|
type => 'i',
|
||||||
|
aliases => [qw(multiply_x)],
|
||||||
},
|
},
|
||||||
'duplicate_y' => {
|
'duplicate_y' => {
|
||||||
label => 'Copies along Y',
|
label => 'Copies along Y',
|
||||||
type => 'i',
|
type => 'i',
|
||||||
|
aliases => [qw(multiply_y)],
|
||||||
},
|
},
|
||||||
'duplicate_distance' => {
|
'duplicate_distance' => {
|
||||||
label => 'Distance between copies',
|
label => 'Distance between copies',
|
||||||
type => 'i',
|
type => 'i',
|
||||||
|
aliases => [qw(multiply_distance)],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -189,8 +192,13 @@ sub load {
|
||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
next if /^\s*#/;
|
next if /^\s*#/;
|
||||||
/^(\w+) = (.+)/ or die "Unreadable configuration file (invalid data at line $.)\n";
|
/^(\w+) = (.+)/ or die "Unreadable configuration file (invalid data at line $.)\n";
|
||||||
my $opt = $Options->{$1} or die "Unknown option $1 at like $.\n";
|
my $key = $1;
|
||||||
set($1, $opt->{deserialize} ? $opt->{deserialize}->($2) : $2);
|
if (!exists $Options->{$key}) {
|
||||||
|
$key = +(grep { $Options->{$_}{aliases} && grep $_ eq $key, @{$Options->{$_}{aliases}} }
|
||||||
|
keys %$Options)[0] or die "Unknown option $1 at line $.\n";
|
||||||
|
}
|
||||||
|
my $opt = $Options->{$key};
|
||||||
|
set($key, $opt->{deserialize} ? $opt->{deserialize}->($2) : $2);
|
||||||
}
|
}
|
||||||
close $fh;
|
close $fh;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue