use strict;
use warnings;
use warnings (exists $ENV{NOVABOOT_TEST} ? (FATAL => 'all') : ());
-use Getopt::Long qw(GetOptionsFromString);
+use Getopt::Long qw(GetOptionsFromString GetOptionsFromArray);
use Pod::Usage;
use File::Basename;
use File::Spec;
@expect_seen = ();
}
-Getopt::Long::Configure(qw/no_ignore_case no_pass_through/);
my %opt_spec;
%opt_spec = (
"amt=s" => \$amt,
# First process target options
{
my $t = defined($explicit_target) ? $explicit_target : $CFG::default_target;
- if ($t) {
+ my @target_expanded;
+ Getopt::Long::Configure(qw/no_ignore_case pass_through/);
+ while ($t) {
exists $CFG::targets{$t} or die("Unknown target '$t' (valid targets are: ".join(", ", sort keys(%CFG::targets)).")");
- GetOptionsFromString($CFG::targets{$t}, %opt_spec);
+
+ undef $explicit_target;
+ my ($ret, $remaining_args) = GetOptionsFromString ($CFG::targets{$t}, ("target|t=s" => \$explicit_target));
+ if (!$ret) { die "Error parsing target $t option"; }
+ push(@target_expanded, @$remaining_args);
+ $t = $explicit_target;
}
+ Getopt::Long::Configure(qw/no_ignore_case no_pass_through/);
+ GetOptionsFromArray(\@target_expanded, %opt_spec) or die ("Error in target definition");
}
# Then process other command line options - some of them may override
create_dummy
WVPASS ./script --iso --target ''
+WVSTART Recursive target definition
+create_dummy
+cat > .novaboot <<EOF
+%targets = (
+ 't1' => '--reset-cmd="echo MyResetCmd"',
+ 't2' => '--target t1',
+);
+EOF
+WVPASS sh -c "./script --target=t2|tee output"
+WVPASS grep -q ^MyResetCmd output
+
+WVSTART Wrong target definition
+create_dummy
+cat > .novaboot <<EOF
+%targets = ('t1' => '--nonsense');
+EOF
+WVPASS sh -c "./script --target=t1 2>&1 |tee output"
+WVPASS grep -q "Error in target definition" output
+
+
# Hi-lock: (("^.*\\(?:WVSTART\\).*$" (0 (quote hi-black-b) t)))