From 6a4d1db679d685d6c95b103bc678087f23e511eb Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Thu, 4 Nov 2010 11:56:03 +0000 Subject: handle commands with unhandled options in a more generic way --- iurt_root_command | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'iurt_root_command') diff --git a/iurt_root_command b/iurt_root_command index 6de4785..e54ce76 100755 --- a/iurt_root_command +++ b/iurt_root_command @@ -157,6 +157,10 @@ $run{todo} = []; \&urpmi, "Run urpmi in chroot" ], ); +my %commands_with_more_args = ( + "--urpmi" => [ \&urpmi, "urpmi" ], +); + open(my $LOG, ">&STDERR"); $run{LOG} = sub { print $LOG @_ }; @@ -165,11 +169,11 @@ plog_init($program_name, $LOG, $run{verbose}); my $todo; -# (blino) do not use mkcd to parse urpmi command line -# I fail to make it no parse arguments after -- on command line -if ($ARGV[0] eq '--urpmi') { +# (blino) do not use mkcd to parse complicated command lines with unhandled options +# I fail to make mkcd not parse arguments after -- on command line +if (my $command = $commands_with_more_args{$ARGV[0]}) { my (undef, @options) = @ARGV; - $todo = [ [ \&urpmi, \@options, "urpmi" ] ]; + $todo = [ [ $command->[0], \@options, $command->[1] ] ]; } else { $todo = parseCommandLine($program_name, \@ARGV, \@params); @ARGV and usage($program_name, \@params, "@ARGV, too many arguments"); -- cgit v1.2.1