Support for legacy multiply options in config files. #7

This commit is contained in:
Alessandro Ranellucci 2011-11-07 17:16:34 +01:00
parent 0b42139e54
commit 80adbb7044

View file

@ -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;
} }