Improve gruntmaster tools
[gruntmaster-data.git] / gruntmaster-problem
index 1b240e0c4b3772973ac5d53f66d140b4bf961acd..afcb1be7135e065fdc342d694a0297bd328f0f11 100755 (executable)
@@ -53,7 +53,7 @@ sub cmd_add{
                $verformat = prompt "[Runner::$runner] Verifier format", -menu => [qw/C CPP MONO JAVA PASCAL PERL PYTHON/];
        }
 
-       $db->problems->create ({
+       my %options = (
                id => $id,
                name => $name,
                level => $level,
@@ -64,48 +64,58 @@ sub cmd_add{
                runner => $runner,
                judge => $judge,
                testcnt => $testcnt,
-               (private => $private)x!! $private,
-               (timeout => $timeout)x!! $timeout,
-               (olimit => $olimit)x!! $olimit,
-               (tests => encode_json \@tests)x!! @tests,
-               (gensource => $gensource)x!! $gensource,
-               (genformat => $genformat)x!! $genformat,
-               (versource => $versource)x!! $versource,
-               (verformat => $verformat)x!! $verformat,
-       });
+       );
+       $options{private} = $private if $private;
+       $options{timeout} = $timeout if $timeout;
+       $options{olimit} = $olimit if $olimit;
+       $options{tests} = encode_json \@tests if @tests;
+       $options{gensource} = $gensource if $gensource;
+       $options{genformat} = $genformat if $genformat;
+       $options{versource} = $versource if $versource;
+       $options{verformat} = $verformat if $verformat;
+       $db->problems->create (\%options);
 
        $db->contest_problems->create({problem => $id, contest => $contest}) if $contest;
-       #PUBLISH genpage => $contest ? "ct/$contest/pb/index.html" : 'pb/index.html';
-       #PUBLISH genpage => $contest ? "ct/$contest/pb/$id.html" : "pb/$id.html";
 }
 
 sub cmd_set{
        my $file;
        GetOptions ( 'file!' => \$file );
-       my ($id, %values) = @ARGV;
+       my ($id, %values) = @_;
        %values = map { $_ => scalar read_file $values{$_} } keys %values if $file;
-       $db->problem($id)->update(\%values);
-       #PUBLISH genpage => 'pb/index.html';
-       #PUBLISH genpage => "pb/$id.html";
+       $db->problem($id)->update(\%values)
 }
 
 sub cmd_get{
-       my ($id, $col) = @ARGV;
+       my ($id, $col) = @_;
        say $db->problem($id)->get_column($col)
 }
 
 sub cmd_list{
        local $, = "\n";
-       say map {$_->id} $db->problems->all;
+       say map {$_->id} $db->problems->all
 }
 
 sub cmd_rm{
-       $db->problem(shift)->delete;
-       #PUBLISH genpage => $contest ? "ct/$contest/pb/index.html" : 'pb/index.html';
+       $db->problem(shift)->delete
 }
 
 sub cmd_show{
-       local $_ = shift or goto &cmd_list;
+       my %columns = $db->problem(shift)->get_columns;
+       print <<END
+Name: $columns{name}
+Author: $columns{author}
+Statement written by: $columns{writer}
+Owner: $columns{owner}
+Level: $columns{level}
+Output limit: $columns{olimit}
+Time limit: $columns{timeout}
+Test count: $columns{testcnt}
+Generator: $columns{generator}
+Runner: $columns{runner}
+Judge: $columns{judge}
+Private: $columns{private}
+END
 }
 
 ##################################################
@@ -137,8 +147,6 @@ gruntmaster-problem - shell interface to Gruntmaster 6000 problems
 
 gruntmaster-problem is a tool for managing problems.
 
-Select the contest with the optional argument I<--contest>.
-
 =over
 
 =item B<list>
@@ -179,10 +187,9 @@ Marius Gavrilescu E<lt>marius@ieval.roE<gt>
 
 Copyright (C) 2014 by Marius Gavrilescu
 
-This library is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+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
This page took 0.011789 seconds and 4 git commands to generate.