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