]> mj.ucw.cz Git - bex.git/commitdiff
"bex job -l" lists jobs in a long format, which includes subjects v3.3
authorMartin Mares <mj@ucw.cz>
Sun, 29 Mar 2015 16:24:05 +0000 (18:24 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 29 Mar 2015 16:24:05 +0000 (18:24 +0200)
lib/bin/bex-job

index 06f0e1394021c8bf0f5962f792bb3086678354f1..21a8a19673485d17f005a964b855913f53737bde 100755 (executable)
@@ -8,14 +8,19 @@ use Getopt::Long;
 use BEX;
 
 my $edit;
+my $long;
 my $queue_name;
 
 sub usage() {
        print <<AMEN ;
 Usage: bex job [<options>] [<job-id>]
 
+If a job-id is given, print information on the given job.
+Otherwise, list all known jobs.
+
 Options:
 -e, --edit             Run editor on the given job (no locking)
+-l, --long             When listing jobs, use long format (with subjects)
 -q, --queue=<name>     Act on the given queue
 AMEN
        exit 0;
@@ -23,6 +28,7 @@ AMEN
 
 GetOptions(
        "e|edit!" => \$edit,
+       "l|long!" => \$long,
        "q|queue=s" => \$queue_name,
        "help" => \&usage,
 ) && @ARGV <= 1 or die "Try `bex job --help' for more information.\n";
@@ -31,8 +37,16 @@ my $queue = BEX::Queue->new($queue_name);
 
 if (!@ARGV) {
        my @jobs = $queue->all_job_ids;
-       for (sort @jobs) {
-               print $_, "\n";
+       for my $id (sort @jobs) {
+               if ($long) {
+                       my $job = $queue->job_metadata($id);
+                       my $has_att = -d $queue->attachment_dir($id);
+                       print $job->name;
+                       print " +ATT" if $has_att;
+                       print "\n";
+               } else {
+                       print $id, "\n";
+               }
        }
        exit 0;
 }