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/];
56 $db->problems->create ({
60 statement
=> $statement,
63 generator
=> $generator,
67 (private
=> $private)x
!! $private,
68 (timeout
=> $timeout)x
!! $timeout,
69 (olimit
=> $olimit)x
!! $olimit,
70 (tests
=> encode_json \
@tests)x
!! @tests,
71 (gensource
=> $gensource)x
!! $gensource,
72 (genformat
=> $genformat)x
!! $genformat,
73 (versource
=> $versource)x
!! $versource,
74 (verformat
=> $verformat)x
!! $verformat,
77 $db->contest_problems->create({problem
=> $id, contest
=> $contest}) if $contest;
78 #PUBLISH genpage => $contest ? "ct/$contest/pb/index.html" : 'pb/index.html';
79 #PUBLISH genpage => $contest ? "ct/$contest/pb/$id.html" : "pb/$id.html";
84 GetOptions
( 'file!' => \
$file );
85 my ($id, %values) = @ARGV;
86 %values = map { $_ => scalar read_file
$values{$_} } keys %values if $file;
87 $db->problem($id)->update(\
%values);
88 #PUBLISH genpage => 'pb/index.html';
89 #PUBLISH genpage => "pb/$id.html";
93 my ($id, $col) = @ARGV;
94 say $db->problem($id)->get_column($col)
99 say map {$_->id} $db->problems->all;
103 $db->problem(shift)->delete;
104 #PUBLISH genpage => $contest ? "ct/$contest/pb/index.html" : 'pb/index.html';
108 local $_ = shift or goto &cmd_list
;
111 ##################################################
113 my $cmd = 'cmd_' . shift;
114 cmd_help
unless exists $main::{$cmd};
125 gruntmaster-problem - shell interface to Gruntmaster 6000 problems
129 gruntmaster-problem add problem_id
130 gruntmaster-problem list
131 gruntmaster-problem rm problem_id
132 gruntmaster-problem show problem_id
133 gruntmaster-problem set [--file] problem_id key value
134 gruntmaster-problem get problem_id key
138 gruntmaster-problem is a tool for managing problems.
140 Select the contest with the optional argument I<--contest>.
146 Prints the list of problems in the selected contest.
150 Prints detailed information about problem I<id>.
154 Adds a new problem with id I<id>.
158 Removes the problem with id I<id>.
160 =item B<set> I<id> I<key> I<value>
162 Sets the I<key> configuration option of problem I<id> to I<value>.
164 =item B<get> I<id> I<key>
166 Get the value of the I<key> configuration option of problem I<id>
168 =item B<set> --file I<id> I<key> I<file>
170 Sets the I<key> configuration option of problem I<id> to the contents of the file I<file>.
176 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
178 =head1 COPYRIGHT AND LICENSE
180 Copyright (C) 2014 by Marius Gavrilescu
182 This library is free software: you can redistribute it and/or modify
183 it under the terms of the GNU Affero General Public License as published by
184 the Free Software Foundation, either version 3 of the License, or
185 (at your option) any later version.
This page took 0.033846 seconds and 4 git commands to generate.