]> iEval git - gruntmaster-page.git/blob - gruntmaster-contest
Add gensrc
[gruntmaster-page.git] / gruntmaster-contest
1 #!/usr/bin/perl -w
2 use v5.14;
3
4 use Gruntmaster::Data qw/contests insert_contest remove_contest contest_name contest_owner contest_start contest_end/;
5
6 use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ];
7 use File::Slurp qw/read_file/;
8 use Term::ANSIColor qw/RED RESET/;
9 use POSIX qw/strftime/;
10 use Date::Parse qw/str2time/;
11
12 ##################################################
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 $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
41 sub cmd_rm{
42 remove_contest shift;
43 }
44
45 ##################################################
46
47 no strict 'refs';
48 my $cmd = 'cmd_' . shift;
49 cmd_help unless exists $main::{$cmd};
50 $cmd->(@ARGV) if exists $main::{$cmd};
51
52 1;
53 __END__
54
55 =encoding utf-8
56
57 =head1 NAME
58
59 gruntmaster-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.047403 seconds and 4 git commands to generate.