Add private to problem hash
[gruntmaster-data.git] / gruntmaster-contest
CommitLineData
014ee8a6
MG
1#!/usr/bin/perl -w
2use v5.14;
3
4use Gruntmaster::Data;
5
6use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ];
7use POSIX qw/strftime/;
8use Date::Parse qw/str2time/;
9
10##################################################
11
12sub cmd_help{
13 exec perldoc => $0
14}
15
16sub cmd_list{
17 local $, = "\n";
18 say contests;
19}
20
21sub cmd_show{
22 local $_ = shift or goto &cmd_list;
23 say "Name: ", contest_name;
24 say "Owner: ", contest_owner;
25 say "Start: ", strftime '%c', localtime contest_start;
26 say "End: ", strftime '%c', localtime contest_end;
27}
28
29sub cmd_add{
30 my $id = shift;
31 my $name = prompt 'Contest name';
32 my $owner = prompt 'Owner';
33 my $start = str2time prompt 'Start time' or die 'Cannot parse time';
34 my $end = str2time prompt 'End time' or die 'Cannot parse time';
35
36 insert_contest $id => name => $name, owner => $owner, start => $start, end => $end;
37 PUBLISH genpage => "ct/$id/index.html";
38 PUBLISH genpage => "ct/index.html";
39}
40
41sub cmd_rm{
42 remove_contest shift;
43 PUBLISH genpage => "ct/index.html";
44}
45
46##################################################
47
48no strict 'refs';
49my $cmd = 'cmd_' . shift;
50cmd_help unless exists $main::{$cmd};
51$cmd->(@ARGV) if exists $main::{$cmd};
52
531;
54__END__
55
56=encoding utf-8
57
58=head1 NAME
59
60gruntmaster-contest - shell interface to Gruntmaster 6000 contests
61
62=head1 SYNOPSIS
63
64 gruntmaster-contest list
65 gruntmaster-contest show id
66 gruntmaster-contest add id
67 gruntmaster-contest rm id
68
69=head1 DESCRIPTION
70
e90402be
MG
71gruntmaster-contest is a tool for managing contests.
72
73=over
74
75=item B<list>
76
77Prints the list of contests.
78
79=item B<show> I<id>
80
81Prints detailed information about the contest with id I<id>.
82
83=item B<add> I<id>
84
85Adds a new contest with id I<id>.
86
87=item B<rm> I<id>
88
89Removes the contest with id I<id>
90
91=back
92
93=head1 AUTHOR
94
95Marius Gavrilescu E<lt>marius@ieval.roE<gt>
96
97=head1 COPYRIGHT AND LICENSE
98
99Copyright (C) 2014 by Marius Gavrilescu
100
101This library is free software: you can redistribute it and/or modify
102it under the terms of the GNU Affero General Public License as published by
103the Free Software Foundation, either version 3 of the License, or
104(at your option) any later version.
014ee8a6
MG
105
106
107=cut
This page took 0.01549 seconds and 4 git commands to generate.