Make perlcritic happy
[gruntmaster-data.git] / lib / Gruntmaster / App / Command / Show.pm
CommitLineData
92f74061
MG
1package Gruntmaster::App::Command::Show;
2
3use 5.014000;
4use warnings;
5
6our $VERSION = '5999.000_004';
7
8use Gruntmaster::App '-command';
9use Gruntmaster::Data;
10use POSIX qw/strftime/;
11
12sub usage_desc { '%c [-cjpu] show id' }
13
14my %TABLE = (
15 contests => \&show_contest,
16 jobs => \&show_job,
17 problems => \&show_problem,
18 users => \&show_user,
19);
20
21sub validate_args {
22 my ($self, $opt, $args) = @_;
23 my @args = @$args;
24 $self->usage_error('No table selected') unless $self->app->table;
25 $self->usage_error('Wrong number of arguments') if @args != 1;
26}
27
28sub execute {
29 my ($self, $opt, $args) = @_;
30 my ($obj) = @$args;
26d0f7b4 31 $TABLE{$self->app->table}->(%{db->select($self->app->table, '*', {id => $obj})->hash});
92f74061
MG
32}
33
34sub show_contest {
35 my (%columns) = @_;
36 $columns{$_} = strftime '%c', localtime $columns{$_} for qw/start stop/;
37
dcf7f640 38 print <<"END"
92f74061
MG
39Name: $columns{name}
40Owner: $columns{owner}
41Start: $columns{start}
42Stop: $columns{stop}
43END
44}
45
dfcf2c13
MG
46sub show_job {
47 my (%columns) = @_;
48 $columns{date} = strftime '%c', localtime $columns{date};
49
50 no warnings 'uninitialized';
dcf7f640 51 print <<"END"
dfcf2c13
MG
52Problem: $columns{problem}
53Contest: $columns{contest}
54Owner: $columns{owner}
55Date: $columns{date}
56Private: @{[$columns{private} ? 'Yes' : 'No']}
57Format: $columns{format}
58Result: $columns{result} ($columns{result_text})
59END
60}
61
92f74061
MG
62sub show_problem {
63 my (%columns) = @_;
64
65 no warnings 'uninitialized';
dcf7f640 66 print <<"END"
92f74061
MG
67Name: $columns{name}
68Author: $columns{author}
69Statement written by: $columns{writer}
70Owner: $columns{owner}
71Level: $columns{level}
72Value (points): $columns{value}
73Private: @{[$columns{private} ? 'Yes' : 'No']}
74
75Generator: $columns{generator}
76Runner: $columns{runner}
77Judge: $columns{judge}
78Test count: $columns{testcnt}
79Time limit: $columns{timeout}
80Output limit (bytes): $columns{olimit}
81END
82}
83
dfcf2c13
MG
84sub show_user {
85 my (%columns) = @_;
86 $columns{since} = strftime '%c', localtime $columns{since};
87
88 no warnings 'uninitialized';
dcf7f640 89 print <<"END"
dfcf2c13
MG
90Email: $columns{name} <$columns{email}>
91Phone: $columns{phone}
92Since: $columns{since}
93Admin: @{[$columns{admin} ? 'Yes' : 'No']}
94Level: $columns{level}
95University: $columns{university}
96Town: $columns{town}
97Country: $columns{country}
98END
99}
100
92f74061
MG
1011;
102__END__
63afa40a
MG
103
104=encoding utf-8
105
106=head1 NAME
107
108Gruntmaster::App::Command::Show - display human-readable information about an object
109
110=head1 SYNOPSIS
111
112 gm -u show MGV
113 gm -p show aplusb
114 gm -c show test_ct
115 gm -j show 100
116
117=head1 DESCRIPTION
118
119The get command takes an object ID and prints information about that
120object in a human-readable format.
121
122=head1 SEE ALSO
123
124L<gm>
125
126=head1 AUTHOR
127
128Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
129
130=head1 COPYRIGHT AND LICENSE
131
132Copyright (C) 2015 by Marius Gavrilescu
133
134This library is free software; you can redistribute it and/or modify
135it under the same terms as Perl itself, either Perl version 5.20.1 or,
136at your option, any later version of Perl 5 you may have available.
137
138
139=cut
This page took 0.018421 seconds and 4 git commands to generate.