Improve gruntmaster tools
[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 $db = Gruntmaster::Data->connect('dbi:Pg:');
12
13 sub cmd_help{
14 exec perldoc => $0
15 }
16
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
31 }
32
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)
45 }
46
47 sub cmd_rerun{
48 $db->job(shift)->rerun
49 }
50
51 ##################################################
52
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
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
74
75 =head1 DESCRIPTION
76
77 gruntmaster-job is a tool for managing jobs.
78
79 =over
80
81 =item B<show> I<id>
82
83 Prints detailed information about the job with id I<id>.
84
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
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
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.
114
115
116 =cut
This page took 0.024428 seconds and 4 git commands to generate.