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 $dsn = $ENV{GRUNTMASTER_DSN
} // 'dbi:Pg:';
15 my $db = Gruntmaster
::Data
->connect($dsn);
23 my $name = prompt
'Problem name';
24 my $private = prompt
('Private?', '-yn') eq 'y';
25 my $contest = prompt
'Contest';
26 my $author = prompt
'Problem author (full name)';
27 my $owner = prompt
'Problem owner (username)';
28 my $level = prompt
'Problem level', -menu
=> "beginner\neasy\nmedium\nhard";
29 my $statement = read_file prompt
'File with problem statement', -complete
=> 'filenames';
30 my $generator = prompt
'Generator', -menu
=> "File\nRun\nUndef";
31 my $runner = prompt
'Runner', -menu
=> "File\nVerifier\nInteractive";
32 my $judge = prompt
'Judge', -menu
=> "Absolute\nPoints";
33 my $testcnt = prompt
'Test count', '-i';
35 my $timeout = prompt
'Time limit (seconds)', '-n';
36 my $olimit = prompt
'Output limit (bytes)', '-i';
37 say 'Memory limits are broken, so I won\'t ask you for one';
39 my (@tests, $gensource, $genformat, $versource, $verformat);
41 if ($generator eq 'Run') {
42 $gensource = read_file prompt
, '[Generator::Run] Generator file name', -complete
=> 'filenames';
43 $genformat = prompt
'[Generator::Run] Generator format', -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
46 if ($runner eq 'File') {
47 my $default = $judge eq 'Points' ?
10 : 'Ok';
48 $tests[$_ - 1] = prompt
"[Runner::File] Score for test ${_} [$default]", -default => $default for 1 .. $testcnt;
51 if ($runner eq 'Verifier' || $runner eq 'Interactive') {
52 say RED
, 'WARNING: Runner::Interactive is experimental', RESET
if $runner eq 'Interactive';
53 $versource = prompt
"[Runner::$runner] Verifier file name", -complete
=> 'filenames';
54 $verformat = prompt
"[Runner::$runner] Verifier format", -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
61 statement
=> $statement,
64 generator
=> $generator,
69 $options{private
} = $private if $private;
70 $options{timeout
} = $timeout if $timeout;
71 $options{olimit
} = $olimit if $olimit;
72 $options{tests
} = encode_json \
@tests if @tests;
73 $options{gensource
} = $gensource if $gensource;
74 $options{genformat
} = $genformat if $genformat;
75 $options{versource
} = $versource if $versource;
76 $options{verformat
} = $verformat if $verformat;
77 $db->problems->create (\
%options);
79 $db->contest_problems->create({problem
=> $id, contest
=> $contest}) if $contest;
84 GetOptions
( 'file!' => \
$file );
85 my ($id, %values) = @_;
86 %values = map { $_ => scalar read_file
$values{$_} } keys %values if $file;
87 $db->problem($id)->update(\
%values)
92 say $db->problem($id)->get_column($col)
97 say map {$_->id} $db->problems->all
101 $db->problem(shift)->delete
105 my %columns = $db->problem(shift)->get_columns;
108 Author: $columns{author}
109 Statement written by: $columns{writer}
110 Owner: $columns{owner}
111 Level: $columns{level}
112 Output limit: $columns{olimit}
113 Time limit: $columns{timeout}
114 Test count: $columns{testcnt}
115 Generator: $columns{generator}
116 Runner: $columns{runner}
117 Judge: $columns{judge}
118 Private: $columns{private}
122 ##################################################
124 my $cmd = 'cmd_' . shift;
125 cmd_help
unless exists $main::{$cmd};
136 gruntmaster-problem - shell interface to Gruntmaster 6000 problems
140 gruntmaster-problem add problem_id
141 gruntmaster-problem list
142 gruntmaster-problem rm problem_id
143 gruntmaster-problem show problem_id
144 gruntmaster-problem set [--file] problem_id key value
145 gruntmaster-problem get problem_id key
149 gruntmaster-problem is a tool for managing problems.
155 Prints the list of problems in the selected contest.
159 Prints detailed information about problem I<id>.
163 Adds a new problem with id I<id>.
167 Removes the problem with id I<id>.
169 =item B<set> I<id> I<key> I<value>
171 Sets the I<key> configuration option of problem I<id> to I<value>.
173 =item B<get> I<id> I<key>
175 Get the value of the I<key> configuration option of problem I<id>
177 =item B<set> --file I<id> I<key> I<file>
179 Sets the I<key> configuration option of problem I<id> to the contents of the file I<file>.
185 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
187 =head1 COPYRIGHT AND LICENSE
189 Copyright (C) 2014 by Marius Gavrilescu
191 This library is free software; you can redistribute it and/or modify
192 it under the same terms as Perl itself, either Perl version 5.18.1 or,
193 at your option, any later version of Perl 5 you may have available.
This page took 0.032198 seconds and 4 git commands to generate.