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