From 556c848ab18da22d07950fb69904658fa2e3e2d8 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 15 Feb 2012 23:56:48 +0100 Subject: [PATCH] All commands now have normal --help --- lib/bin/add | 24 +++++++++++++++--------- lib/bin/job | 14 ++++++++++---- lib/bin/ls | 22 ++++++++++++++-------- lib/bin/mach | 10 ++++++++-- lib/bin/prun | 16 +++++++++++----- lib/bin/queue | 12 +++++++++--- lib/bin/run | 22 ++++++++++++++-------- 7 files changed, 81 insertions(+), 39 deletions(-) diff --git a/lib/bin/add b/lib/bin/add index 7483ea8..64945f9 100755 --- a/lib/bin/add +++ b/lib/bin/add @@ -16,15 +16,8 @@ my $requeue_id; my $given_subject; my $given_template; -GetOptions( - "b|body=s" => \$given_body, - "g|go!" => \$given_go, - "i|id=s" => \$given_id, - "q|queue=s" => \$queue_name, - "r|requeue=s" => \$requeue_id, - "s|subject=s" => \$given_subject, - "t|template=s" => \$given_template, -) or die <] [!] ... Options: @@ -36,6 +29,19 @@ Options: -s, --subject= Set subject of the new job -t, --template= Load job template (headers and body) from the given file AMEN + exit 0; +} + +GetOptions( + "b|body=s" => \$given_body, + "g|go!" => \$given_go, + "i|id=s" => \$given_id, + "q|queue=s" => \$queue_name, + "r|requeue=s" => \$requeue_id, + "s|subject=s" => \$given_subject, + "t|template=s" => \$given_template, + "help" => \&usage, +) or die "Try `bex add --help' for more information.\n"; # Prepare machine set @ARGV or die "No machines specified\n"; diff --git a/lib/bin/job b/lib/bin/job index 11e8e11..48f98a8 100755 --- a/lib/bin/job +++ b/lib/bin/job @@ -10,16 +10,22 @@ use BEX; my $edit; my $queue_name; -GetOptions( - "e|edit!" => \$edit, - "q|queue=s" => \$queue_name, -) && @ARGV == 1 or die <] Options: -e, --edit Run editor on the given job (no locking) -q, --queue= Act on the given queue AMEN + exit 0; +} + +GetOptions( + "e|edit!" => \$edit, + "q|queue=s" => \$queue_name, + "help" => \&usage, +) && @ARGV == 1 or die "Try `bex job --help' for more information.\n"; my $queue = BEX::Queue->new($queue_name); my $fn = $queue->job_file($ARGV[0]); diff --git a/lib/bin/ls b/lib/bin/ls index 79db513..a575983 100755 --- a/lib/bin/ls +++ b/lib/bin/ls @@ -16,14 +16,8 @@ my $op_move_to; my $queue_name; my $given_job; -GetOptions( - "by-job!" => \$op_by_job, - "h|by-host!" => \$op_by_host, - "rm!" => \$op_rm, - "move-to=s" => \$op_move_to, - "j|job=s" => \$given_job, - "q|queue=s" => \$queue_name, -) or die <] [[!] ...] Actions: @@ -36,6 +30,18 @@ Options: -j, --job= Act on the specified job (default: on all) -q, --queue= Act on the given queue AMEN + exit 0; +} + +GetOptions( + "by-job!" => \$op_by_job, + "h|by-host!" => \$op_by_host, + "rm!" => \$op_rm, + "move-to=s" => \$op_move_to, + "j|job=s" => \$given_job, + "q|queue=s" => \$queue_name, + "help" => \&usage, +) or die "Try `bex ls --help' for more information.\n"; my @machines = BEX::Config::parse_machine_list(@ARGV ? @ARGV : '*'); my $queue = BEX::Queue->new($queue_name); diff --git a/lib/bin/mach b/lib/bin/mach index 69c26c6..e63f180 100755 --- a/lib/bin/mach +++ b/lib/bin/mach @@ -10,13 +10,19 @@ use BEX; my $edit; my $queue_name; -GetOptions( -) && @ARGV == 0 or die <] Options: None defined so far. AMEN + exit 0; +} + +GetOptions( + "help" => \&usage, +) && @ARGV == 0 or die "Try `bex mach --help' for more information.\n"; my $machines = \%BEX::Config::machines; diff --git a/lib/bin/prun b/lib/bin/prun index ba17cd4..4900ef2 100755 --- a/lib/bin/prun +++ b/lib/bin/prun @@ -13,11 +13,8 @@ my $queue_name; my $screen_session = 'BEX'; my $text_mode; -GetOptions( - "q|queue=s" => \$queue_name, - "session=s" => \$screen_session, - "text!" => \$text_mode, -) or die <] [[!] ...] Options: @@ -26,6 +23,15 @@ Options: session (default: BEX) --text Use textual user interface instead of curses AMEN + exit 0; +} + +GetOptions( + "q|queue=s" => \$queue_name, + "session=s" => \$screen_session, + "text!" => \$text_mode, + "help" => \&usage, +) or die "Try `bex prun --help' for more information.\n"; system 'screen', '-S', $screen_session, '-X', 'select', '.'; !$? or die "Screen session $screen_session not found\n"; diff --git a/lib/bin/queue b/lib/bin/queue index 1ebca3a..aa90755 100755 --- a/lib/bin/queue +++ b/lib/bin/queue @@ -9,9 +9,8 @@ use BEX; my $init; -GetOptions( - "init!" => \$init, -) or die <] Subcommands: @@ -21,6 +20,13 @@ ls List all queues Options: None defined so far. AMEN + exit 0; +} + +GetOptions( + "init!" => \$init, + "help" => \&usage, +) or die "Try `bex queue --help' for more information.\n"; my $op = shift @ARGV // 'ls'; diff --git a/lib/bin/run b/lib/bin/run index f90c96f..66b9efc 100755 --- a/lib/bin/run +++ b/lib/bin/run @@ -7,6 +7,18 @@ use warnings; use Getopt::Long; use BEX; +sub usage() { + print <] [[!] ...] + +Options: +-j, --job= Run only the specified job +-q, --queue= Select job queue + --status-fifo= Send status updates to the given named pipe +AMEN + exit 0; +} + my $given_job; my $queue_name; my $status_fifo; @@ -15,14 +27,8 @@ GetOptions( "j|job=s" => \$given_job, "q|queue=s" => \$queue_name, "s|status-fifo=s" => \$status_fifo, -) or die <] [[!] ...] - -Options: --j, --job= Run only the specified job --q, --queue= Select job queue - --status-fifo= Send status updates to the given named pipe -AMEN + "help" => \&usage, +) or die "Try `bex run --help' for more information.\n"; my $status_fd; if (defined $status_fifo) { -- 2.39.2