X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=gruntmaster-contest;h=856faae6d7698fbc08b396ccb6f07defd7b92444;hb=347ea1e4cea0a3bb98bbcb978b6c8d3296e7707f;hp=c2608c9300c26dcdb3915337fe13df12d076fbd4;hpb=014ee8a614839ded741f61979d979cdd4f20044c;p=gruntmaster-data.git diff --git a/gruntmaster-contest b/gruntmaster-contest index c2608c9..856faae 100755 --- a/gruntmaster-contest +++ b/gruntmaster-contest @@ -9,21 +9,27 @@ use Date::Parse qw/str2time/; ################################################## +my $dsn = $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:'; +my $db = Gruntmaster::Data->connect($dsn); + sub cmd_help{ exec perldoc => $0 } sub cmd_list{ local $, = "\n"; - say contests; + say map { $_->id } $db->contests->all; } sub cmd_show{ - local $_ = shift or goto &cmd_list; - say "Name: ", contest_name; - say "Owner: ", contest_owner; - say "Start: ", strftime '%c', localtime contest_start; - say "End: ", strftime '%c', localtime contest_end; + my %columns = $db->contest(shift)->get_columns; + $columns{$_} = strftime '%c', localtime $columns{$_} for qw/start stop/; + print < name => $name, owner => $owner, start => $start, end => $end; - PUBLISH genpage => "ct/$id/index.html"; - PUBLISH genpage => "ct/index.html"; + $db->contests->create({id => $id, name => $name, owner => $owner, start => $start, stop => $stop}) } sub cmd_rm{ - remove_contest shift; - PUBLISH genpage => "ct/index.html"; + $db->contest(shift)->delete +} + +sub cmd_get{ + my ($id, $col) = @_; + say $db->contest($id)->get_column($col) +} + +sub cmd_set{ + my ($id, %values) = @_; + $db->contest($id)->update(\%values) } ################################################## @@ -65,9 +78,52 @@ gruntmaster-contest - shell interface to Gruntmaster 6000 contests gruntmaster-contest show id gruntmaster-contest add id gruntmaster-contest rm id + gruntmaster-contest get id key + gruntmaster-contest set id key value =head1 DESCRIPTION +gruntmaster-contest is a tool for managing contests. + +=over + +=item B + +Prints the list of contests. + +=item B I + +Prints detailed information about the contest with id I. + +=item B I + +Adds a new contest with id I. + +=item B I + +Removes the contest with id I. + +=item B I I I + +Sets the I configuration option of contest I to I. + +=item B I I + +Get the value of the I configuration option of contest I. + +=back + +=head1 AUTHOR + +Marius Gavrilescu Emarius@ieval.roE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 by Marius Gavrilescu + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.18.1 or, +at your option, any later version of Perl 5 you may have available. =cut