X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=gruntmaster-job;h=06e3fe14d44edb51f091df1ad96b0a2a839da13e;hb=26d60269bc13d62a648cf4772f2b58f87bbcd2f3;hp=23e9cd2870ea57553a103d4eada12462010a7687;hpb=e90402be973e38af429acb2d1adc789868914940;p=gruntmaster-data.git diff --git a/gruntmaster-job b/gruntmaster-job index 23e9cd2..06e3fe1 100755 --- a/gruntmaster-job +++ b/gruntmaster-job @@ -4,47 +4,53 @@ use v5.14; use Gruntmaster::Data; use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ]; -use File::Slurp qw/read_file/; -use Getopt::Long; -use Term::ANSIColor qw/RED RESET/; use POSIX qw/strftime/; ################################################## -my $contest; +my $dsn = $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:'; +my $db = Gruntmaster::Data->connect($dsn); sub cmd_help{ exec perldoc => $0 } -sub cmd_card{ - say jobcard; +sub cmd_show{ + my %columns = $db->job(shift)->get_columns; + $columns{date} = strftime '%c', localtime $columns{date}; + $columns{private} = $columns{private} ? 'yes' : 'no'; + + print <job(shift)->delete +} + +sub cmd_get{ + my ($id, $col) = @_; + say $db->job($id)->get_column($col) +} + +sub cmd_set{ + my ($id, %values) = @_; + $db->job($id)->update(\%values) } sub cmd_rerun{ - local $_ = shift or goto &cmd_list; - clean_job; - $contest//=''; - PUBLISH jobs => "$contest.$_"; + $db->job(shift)->rerun } ################################################## -GetOptions ( 'contest=s' => \$contest ); -local $Gruntmaster::Data::contest = $contest; my $cmd = 'cmd_' . shift; cmd_help unless exists $main::{$cmd}; no strict 'refs'; @@ -61,26 +67,34 @@ gruntmaster-job - shell interface to Gruntmaster 6000 job log =head1 SYNOPSIS - gruntmaster-job [--contest=mycontest] card - gruntmaster-job [--contest=mycontest] show 5 - gruntmaster-job [--contest=mycontest] rerun 7 + gruntmaster-job show id + gruntmaster-job rm id + gruntmaster-job get id key + gruntmaster-job set id key value + gruntmaster-job rerun id =head1 DESCRIPTION gruntmaster-job is a tool for managing jobs. -Select the contest with the optional argument I<--contest>. - =over -=item B - -Prints the number of jobs in the selected contest. - =item B I Prints detailed information about the job with id I. +=item B I + +Removes the job with id I. + +=item B I I I + +Sets the I configuration option of job I to I. + +=item B I I + +Get the value of the I configuration option of job I. + =item B I Reruns job I. @@ -95,10 +109,9 @@ Marius Gavrilescu Emarius@ieval.roE Copyright (C) 2014 by Marius Gavrilescu -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.18.1 or, +at your option, any later version of Perl 5 you may have available. =cut