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