Fix gruntmaster-contest
[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
08b6a201
MG
12my $db = Gruntmaster::Data->connect('dbi:Pg:');
13
014ee8a6
MG
14sub cmd_help{
15 exec perldoc => $0
16}
17
18sub cmd_list{
19 local $, = "\n";
20 say contests;
21}
22
23sub cmd_show{
08b6a201
MG
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;
014ee8a6
MG
29}
30
31sub 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';
08b6a201 36 my $stop = str2time prompt 'Stop time' or die 'Cannot parse time';
014ee8a6 37
08b6a201
MG
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";
014ee8a6
MG
42}
43
44sub cmd_rm{
08b6a201
MG
45# remove_contest shift;
46# PUBLISH genpage => "ct/index.html";
014ee8a6
MG
47}
48
49##################################################
50
51no strict 'refs';
52my $cmd = 'cmd_' . shift;
53cmd_help unless exists $main::{$cmd};
54$cmd->(@ARGV) if exists $main::{$cmd};
55
561;
57__END__
58
59=encoding utf-8
60
61=head1 NAME
62
63gruntmaster-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
e90402be
MG
74gruntmaster-contest is a tool for managing contests.
75
76=over
77
78=item B<list>
79
80Prints the list of contests.
81
82=item B<show> I<id>
83
84Prints detailed information about the contest with id I<id>.
85
86=item B<add> I<id>
87
88Adds a new contest with id I<id>.
89
90=item B<rm> I<id>
91
92Removes the contest with id I<id>
93
94=back
95
96=head1 AUTHOR
97
98Marius Gavrilescu E<lt>marius@ieval.roE<gt>
99
100=head1 COPYRIGHT AND LICENSE
101
102Copyright (C) 2014 by Marius Gavrilescu
103
104This library is free software: you can redistribute it and/or modify
105it under the terms of the GNU Affero General Public License as published by
106the Free Software Foundation, either version 3 of the License, or
107(at your option) any later version.
014ee8a6
MG
108
109
110=cut
This page took 0.0165 seconds and 4 git commands to generate.