]> git.mjollnir.org Git - cil.git/commitdiff
Simplify main program more
authorSam Vilain <sam.vilain@catalyst.net.nz>
Sun, 22 Jun 2008 23:20:29 +0000 (11:20 +1200)
committerSam Vilain <sam.vilain@catalyst.net.nz>
Sun, 22 Jun 2008 23:20:29 +0000 (11:20 +1200)
Already checked that the command exists, no need to repeat.  Also
can remove the hash of commands at the top.

bin/cil

diff --git a/bin/cil b/bin/cil
index 9dafe8c3dec375394382f0de9a1ee2e3a05ea798..a12862181cdb4e56d35a0b2dc8ecfb55932f03b0 100755 (executable)
--- 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);
 }
 
 ## ----------------------------------------------------------------------------