From: Sam Vilain Date: Sun, 22 Jun 2008 23:20:29 +0000 (+1200) Subject: Simplify main program more X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=65ea512fdc712dca3cae1fe149e4fbaccaa50249;p=cil.git Simplify main program more Already checked that the command exists, no need to repeat. Also can remove the hash of commands at the top. --- diff --git a/bin/cil b/bin/cil index 9dafe8c..a128621 100755 --- a/bin/cil +++ b/bin/cil @@ -39,19 +39,6 @@ use CIL::Attachment; use constant VERSION => '0.2'; -my $COMMANDS = { - init => 1, - list => 1, - summary => 1, - add => 1, - show => 1, - status => 1, - edit => 1, - comment => 1, - attach => 1, - extract => 1, -}; - my @IN_OPTS = ( 'p=s', # p = path 'path>p', # for 'add' @@ -108,18 +95,17 @@ EOF if @ARGV == 0; my $command = shift @ARGV; - Getopt::Mixed::abortMsg("'$command' is not a valid cil command.") - unless defined $command and exists $COMMANDS->{$command}; - - my $cil = CIL->new(); - + if ( not defined $command ) { + Getopt::Mixed::abortMsg("no command specified"); + } no strict 'refs'; if ( not defined &{"cmd_$command"} ) { - fatal("program error when trying command '$command'"); - } - else { - &{"cmd_$command"}($cil, $args, @ARGV); + Getopt::Mixed::abortMsg("'$command' is not a valid cil command."); } + + my $cil = CIL->new(); + + &{"cmd_$command"}($cil, $args, @ARGV); } ## ----------------------------------------------------------------------------