Bump version and update Changes
[gruntmaster-data.git] / gruntmaster-job
1 #!/usr/bin/perl -w
2 use v5.14;
3
4 use Gruntmaster::Data;
5
6 use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ];
7 use POSIX qw/strftime/;
8
9 ##################################################
10
11 my $dsn = $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:';
12 my $db = Gruntmaster::Data->connect($dsn);
13
14 sub cmd_help{
15 exec perldoc => $0
16 }
17
18 sub cmd_show{
19 my %columns = $db->job(shift)->get_columns;
20 $columns{date} = strftime '%c', localtime $columns{date};
21 $columns{private} = $columns{private} ? 'yes' : 'no';
22
23 print <<END
24 Date: $columns{date}
25 Owner: $columns{owner}
26 Problem: $columns{problem}
27 Format: $columns{format}
28 Daemon: $columns{daemon}
29 Result text: $columns{result_text}
30 Private: $columns{private}
31 END
32 }
33
34 sub cmd_rm{
35 my ($id) = @_;
36 $db->job($id)->delete;
37 }
38
39 sub cmd_get{
40 my ($id, $col) = @_;
41 say $db->job($id)->get_column($col)
42 }
43
44 sub cmd_set{
45 my ($id, %values) = @_;
46 $db->job($id)->update(\%values);
47 }
48
49 sub cmd_rerun{
50 my ($id) = @_;
51 $db->job($id)->rerun;
52 }
53
54 ##################################################
55
56 my $cmd = 'cmd_' . shift;
57 cmd_help unless exists $main::{$cmd};
58 no strict 'refs';
59 $cmd->(@ARGV) if exists $main::{$cmd};
60
61 1;
62 __END__
63
64 =encoding utf-8
65
66 =head1 NAME
67
68 gruntmaster-job - shell interface to Gruntmaster 6000 job log
69
70 =head1 SYNOPSIS
71
72 gruntmaster-job show id
73 gruntmaster-job rm id
74 gruntmaster-job get id key
75 gruntmaster-job set id key value
76 gruntmaster-job rerun id
77
78 =head1 DESCRIPTION
79
80 gruntmaster-job is a tool for managing jobs.
81
82 =over
83
84 =item B<show> I<id>
85
86 Prints detailed information about the job with id I<id>.
87
88 =item B<rm> I<id>
89
90 Removes the job with id I<id>.
91
92 =item B<set> I<id> I<key> I<value>
93
94 Sets the I<key> configuration option of job I<id> to I<value>.
95
96 =item B<get> I<id> I<key>
97
98 Get the value of the I<key> configuration option of job I<id>.
99
100 =item B<rerun> I<id>
101
102 Reruns job I<id>.
103
104 =back
105
106 =head1 AUTHOR
107
108 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
109
110 =head1 COPYRIGHT AND LICENSE
111
112 Copyright (C) 2014 by Marius Gavrilescu
113
114 This library is free software; you can redistribute it and/or modify
115 it under the same terms as Perl itself, either Perl version 5.18.1 or,
116 at your option, any later version of Perl 5 you may have available.
117
118
119 =cut
This page took 0.027888 seconds and 4 git commands to generate.