]> iEval git - gruntmaster-page.git/blame - gruntmaster-contest
Remove generators which are now articles
[gruntmaster-page.git] / gruntmaster-contest
CommitLineData
4d44768e
MG
1#!/usr/bin/perl -w
2use v5.14;
3
4use Gruntmaster::Data qw/contests insert_contest remove_contest contest_name contest_owner contest_start contest_end/;
5
6use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ];
7use File::Slurp qw/read_file/;
8use Term::ANSIColor qw/RED RESET/;
9use POSIX qw/strftime/;
10use Date::Parse qw/str2time/;
11
12##################################################
13
14sub cmd_help{
15 exec perldoc => $0
16}
17
18sub cmd_list{
19 local $, = "\n";
20 say contests;
21}
22
23sub 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
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';
36 my $end = str2time prompt 'End time' or die 'Cannot parse time';
37
38 insert_contest $id => name => $name, owner => $owner, start => $start, end => $end;
39}
40
41sub cmd_rm{
42 remove_contest shift;
43}
44
45##################################################
46
47no strict 'refs';
48my $cmd = 'cmd_' . shift;
49cmd_help unless exists $main::{$cmd};
50$cmd->(@ARGV) if exists $main::{$cmd};
51
521;
53__END__
54
55=encoding utf-8
56
57=head1 NAME
58
59gruntmaster-contest - shell interface to Gruntmaster 6000 contests
60
61=head1 SYNOPSIS
62
63 gruntmaster-contest list
64 gruntmaster-contest show id
65 gruntmaster-contest add id
66 gruntmaster-contest rm id
67
68=head1 DESCRIPTION
69
70
71
72=cut
This page took 0.025369 seconds and 4 git commands to generate.