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