]>
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 | ||
30e287c3 MG |
11 | my $dsn = $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:'; |
12 | my $db = Gruntmaster::Data->connect($dsn); | |
014ee8a6 MG |
13 | |
14 | sub cmd_help{ | |
15 | exec perldoc => $0 | |
16 | } | |
17 | ||
4af36605 MG |
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 | |
014ee8a6 MG |
32 | } |
33 | ||
4af36605 | 34 | sub cmd_rm{ |
edfc5928 MG |
35 | my ($id) = @_; |
36 | $db->job($id)->delete; | |
37 | purge '/log/'; | |
38 | purge "/log/$id"; | |
4af36605 MG |
39 | } |
40 | ||
41 | sub cmd_get{ | |
42 | my ($id, $col) = @_; | |
43 | say $db->job($id)->get_column($col) | |
44 | } | |
45 | ||
46 | sub cmd_set{ | |
47 | my ($id, %values) = @_; | |
edfc5928 MG |
48 | $db->job($id)->update(\%values); |
49 | purge '/log/'; | |
50 | purge "/log/$id"; | |
014ee8a6 MG |
51 | } |
52 | ||
53 | sub cmd_rerun{ | |
edfc5928 MG |
54 | my ($id) = @_; |
55 | $db->job($id)->rerun; | |
56 | purge '/log/'; | |
57 | purge "/log/$id"; | |
014ee8a6 MG |
58 | } |
59 | ||
60 | ################################################## | |
61 | ||
014ee8a6 MG |
62 | my $cmd = 'cmd_' . shift; |
63 | cmd_help unless exists $main::{$cmd}; | |
64 | no strict 'refs'; | |
65 | $cmd->(@ARGV) if exists $main::{$cmd}; | |
66 | ||
67 | 1; | |
68 | __END__ | |
69 | ||
70 | =encoding utf-8 | |
71 | ||
72 | =head1 NAME | |
73 | ||
74 | gruntmaster-job - shell interface to Gruntmaster 6000 job log | |
75 | ||
76 | =head1 SYNOPSIS | |
77 | ||
4af36605 MG |
78 | gruntmaster-job show id |
79 | gruntmaster-job rm id | |
80 | gruntmaster-job get id key | |
81 | gruntmaster-job set id key value | |
82 | gruntmaster-job rerun id | |
014ee8a6 MG |
83 | |
84 | =head1 DESCRIPTION | |
85 | ||
e90402be MG |
86 | gruntmaster-job is a tool for managing jobs. |
87 | ||
e90402be MG |
88 | =over |
89 | ||
e90402be MG |
90 | =item B<show> I<id> |
91 | ||
92 | Prints detailed information about the job with id I<id>. | |
93 | ||
4af36605 MG |
94 | =item B<rm> I<id> |
95 | ||
96 | Removes the job with id I<id>. | |
97 | ||
98 | =item B<set> I<id> I<key> I<value> | |
99 | ||
100 | Sets the I<key> configuration option of job I<id> to I<value>. | |
101 | ||
102 | =item B<get> I<id> I<key> | |
103 | ||
104 | Get the value of the I<key> configuration option of job I<id>. | |
105 | ||
e90402be MG |
106 | =item B<rerun> I<id> |
107 | ||
108 | Reruns job I<id>. | |
109 | ||
110 | =back | |
111 | ||
112 | =head1 AUTHOR | |
113 | ||
114 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
115 | ||
116 | =head1 COPYRIGHT AND LICENSE | |
117 | ||
118 | Copyright (C) 2014 by Marius Gavrilescu | |
119 | ||
4af36605 MG |
120 | This library is free software; you can redistribute it and/or modify |
121 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
122 | at your option, any later version of Perl 5 you may have available. | |
014ee8a6 MG |
123 | |
124 | ||
125 | =cut |