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