]> mj.ucw.cz Git - bex.git/blobdiff - bex
Maint: mkdir -p
[bex.git] / bex
diff --git a/bex b/bex
index 0fe8495b06207bb1325bc29dfbccae3ee4dd6398..f4db56f0fe90b25751ece0ef953eb50cfa3f3caa 100755 (executable)
--- a/bex
+++ b/bex
@@ -9,12 +9,8 @@ use Getopt::Long;
 my $bex_home = $ENV{"BEX_HOME"} // ".";
 my $bex_lib = $ENV{"BEX_LIB"} // "lib";
 
 my $bex_home = $ENV{"BEX_HOME"} // ".";
 my $bex_lib = $ENV{"BEX_LIB"} // "lib";
 
-Getopt::Long::Configure('require_order');
-GetOptions(
-       "home=s" => \$bex_home,
-       "lib=s" => \$bex_lib,
-       "help" => sub {
-                       print <<AMEN ;
+sub show_help() {
+       print <<AMEN ;
 Usage: bex <general-options> <command> <command-options> <args>
 
 General options:
 Usage: bex <general-options> <command> <command-options> <args>
 
 General options:
@@ -23,19 +19,26 @@ General options:
 
 Commands (and aliases):
 add (a)                Add new jobs to a queue
 
 Commands (and aliases):
 add (a)                Add new jobs to a queue
+help           Show this help
 job            Operations on queued jobs
 job            Operations on queued jobs
-ls (l)         Show queues and jobs on them
 mach           List known machines and groups
 prun (pr)      Parallel version of `run'
 mach           List known machines and groups
 prun (pr)      Parallel version of `run'
-queue          Operations on queues
+qman           Management of queues
+queue (q)      Show queues and jobs on them
 run (r)                Run queued jobs
 AMEN
 run (r)                Run queued jobs
 AMEN
-                       exit 0;
-               },
+       exit 0;
+}
+
+Getopt::Long::Configure('require_order');
+GetOptions(
+       "home=s" => \$bex_home,
+       "lib=s" => \$bex_lib,
+       "help" => \&show_help,
        "version" => sub {
                        print "BEX 3.0 (c) 2011-2012 Martin Mares <mj\@ucw.cz>\n";
                },
        "version" => sub {
                        print "BEX 3.0 (c) 2011-2012 Martin Mares <mj\@ucw.cz>\n";
                },
-) or die "Try `bex --help' for more information.\n";
+) or die "Try `bex help' for more information.\n";
 Getopt::Long::Configure('default');
 
 if (!-d $bex_home) {
 Getopt::Long::Configure('default');
 
 if (!-d $bex_home) {
@@ -52,10 +55,12 @@ if (!-f "$bex_lib/perl/BEX.pm") {
 my $sub = shift @ARGV;
 $sub =~ /^[0-9a-zA-Z]+$/ or die "Invalid subcommand $sub\n";
 
 my $sub = shift @ARGV;
 $sub =~ /^[0-9a-zA-Z]+$/ or die "Invalid subcommand $sub\n";
 
+if ($sub eq 'help') { show_help(); }
+
 my %aliases = (
        'a' => 'add',
 my %aliases = (
        'a' => 'add',
-       'l' => 'ls',
        'p' => 'prun',
        'p' => 'prun',
+       'q' => 'queue',
        'r' => 'run',
 );
 if (defined $aliases{$sub}) { $sub = $aliases{$sub}; }
        'r' => 'run',
 );
 if (defined $aliases{$sub}) { $sub = $aliases{$sub}; }