afcb1be7135e065fdc342d694a0297bd328f0f11
6 use IO
::Prompter
[ -style
=> 'bold', '-stdio', '-verbatim' ];
7 use File
::Slurp qw
/read_file/;
8 use JSON qw
/encode_json/;
9 use Term
::ANSIColor qw
/RED RESET/;
10 use Getopt
::Long qw
/:config require_order/;
12 ##################################################
14 my $db = Gruntmaster
::Data
->connect('dbi:Pg:');
22 my $name = prompt
'Problem name';
23 my $private = prompt
('Private?', '-yn') eq 'y';
24 my $contest = prompt
'Contest';
25 my $author = prompt
'Problem author (full name)';
26 my $owner = prompt
'Problem owner (username)';
27 my $level = prompt
'Problem level', -menu
=> "beginner\neasy\nmedium\nhard";
28 my $statement = read_file prompt
'File with problem statement', -complete
=> 'filenames';
29 my $generator = prompt
'Generator', -menu
=> "File\nRun\nUndef";
30 my $runner = prompt
'Runner', -menu
=> "File\nVerifier\nInteractive";
31 my $judge = prompt
'Judge', -menu
=> "Absolute\nPoints";
32 my $testcnt = prompt
'Test count', '-i';
34 my $timeout = prompt
'Time limit (seconds)', '-n';
35 my $olimit = prompt
'Output limit (bytes)', '-i';
36 say 'Memory limits are broken, so I won\'t ask you for one';
38 my (@tests, $gensource, $genformat, $versource, $verformat);
40 if ($generator eq 'Run') {
41 $gensource = read_file prompt
, '[Generator::Run] Generator file name', -complete
=> 'filenames';
42 $genformat = prompt
'[Generator::Run] Generator format', -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
45 if ($runner eq 'File') {
46 my $default = $judge eq 'Points' ?
10 : 'Ok';
47 $tests[$_ - 1] = prompt
"[Runner::File] Score for test ${_} [$default]", -default => $default for 1 .. $testcnt;
50 if ($runner eq 'Verifier' || $runner eq 'Interactive') {
51 say RED
, 'WARNING: Runner::Interactive is experimental', RESET
if $runner eq 'Interactive';
52 $versource = prompt
"[Runner::$runner] Verifier file name", -complete
=> 'filenames';
53 $verformat = prompt
"[Runner::$runner] Verifier format", -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
60 statement
=> $statement,
63 generator
=> $generator,
68 $options{private
} = $private if $private;
69 $options{timeout
} = $timeout if $timeout;
70 $options{olimit
} = $olimit if $olimit;
71 $options{tests
} = encode_json \
@tests if @tests;
72 $options{gensource
} = $gensource if $gensource;
73 $options{genformat
} = $genformat if $genformat;
74 $options{versource
} = $versource if $versource;
75 $options{verformat
} = $verformat if $verformat;
76 $db->problems->create (\
%options);
78 $db->contest_problems->create({problem
=> $id, contest
=> $contest}) if $contest;
83 GetOptions
( 'file!' => \
$file );
84 my ($id, %values) = @_;
85 %values = map { $_ => scalar read_file
$values{$_} } keys %values if $file;
86 $db->problem($id)->update(\
%values)
91 say $db->problem($id)->get_column($col)
96 say map {$_->id} $db->problems->all
100 $db->problem(shift)->delete
104 my %columns = $db->problem(shift)->get_columns;
107 Author: $columns{author}
108 Statement written by: $columns{writer}
109 Owner: $columns{owner}
110 Level: $columns{level}
111 Output limit: $columns{olimit}
112 Time limit: $columns{timeout}
113 Test count: $columns{testcnt}
114 Generator: $columns{generator}
115 Runner: $columns{runner}
116 Judge: $columns{judge}
117 Private: $columns{private}
121 ##################################################
123 my $cmd = 'cmd_' . shift;
124 cmd_help
unless exists $main::{$cmd};
135 gruntmaster-problem - shell interface to Gruntmaster 6000 problems
139 gruntmaster-problem add problem_id
140 gruntmaster-problem list
141 gruntmaster-problem rm problem_id
142 gruntmaster-problem show problem_id
143 gruntmaster-problem set [--file] problem_id key value
144 gruntmaster-problem get problem_id key
148 gruntmaster-problem is a tool for managing problems.
154 Prints the list of problems in the selected contest.
158 Prints detailed information about problem I<id>.
162 Adds a new problem with id I<id>.
166 Removes the problem with id I<id>.
168 =item B<set> I<id> I<key> I<value>
170 Sets the I<key> configuration option of problem I<id> to I<value>.
172 =item B<get> I<id> I<key>
174 Get the value of the I<key> configuration option of problem I<id>
176 =item B<set> --file I<id> I<key> I<file>
178 Sets the I<key> configuration option of problem I<id> to the contents of the file I<file>.
184 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
186 =head1 COPYRIGHT AND LICENSE
188 Copyright (C) 2014 by Marius Gavrilescu
190 This library is free software; you can redistribute it and/or modify
191 it under the same terms as Perl itself, either Perl version 5.18.1 or,
192 at your option, any later version of Perl 5 you may have available.
This page took 0.035656 seconds and 3 git commands to generate.