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