6 use IO
::Prompter
[ -style
=> 'bold', '-stdio', '-verbatim' ];
7 use File
::Slurp qw
/read_file/;
8 use Term
::ANSIColor qw
/RED RESET/;
9 use Getopt
::Long qw
/:config require_order/;
11 ##################################################
20 my ($meta, $name, $prefix) = @_;
21 my $filename = prompt
'$prefix filename', -complete
=> 'filenames';
22 $meta->{files
}{$name}{content
} = read_file
$filename;
23 $meta->{files
}{$name}{format
} = prompt
'$prefix format', -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
24 $meta->{files
}{$name}{name
} = prompt
"$prefix filename [$filename]", -default => $filename;
29 my $name = prompt
'Problem name';
30 my $private = prompt
('Private?', '-yn') eq 'y';
31 my $author = prompt
'Problem author (full name)';
32 my $owner = prompt
'Problem owner (username)';
33 my $level = prompt
'Problem level', -menu
=> "beginner\neasy\nmedium\nhard";
34 my $statement = read_file prompt
'File with problem statement', -complete
=> 'filenames';
36 my $generator = prompt
'Generator', -menu
=> "File\nRun\nUndef";
37 my $runner = prompt
'Runner', -menu
=> "File\nVerifier\nInteractive";
38 my $judge = prompt
'Judge', -menu
=> "Absolute\nPoints";
39 my $testcnt = prompt
'Test count', '-i';
41 my $timeout = prompt
'Time limit (seconds)', '-n';
42 my $olimit = prompt
'Output limit (bytes)', '-i';
43 say 'Memory limits are broken, so I won\'t ask you for one';
45 prompt_file \
%meta, gen
=> '[Generator::Run] Generator' if $generator eq 'Run';
47 if ($runner eq 'File') {
48 $meta{tests
}[$_ - 1] = prompt
"[Runner::File] Score for test ${_} [10]", '-i', -default => 10 for 1 .. $testcnt;
51 prompt_file \
%meta, ver
=> '[Runner::Verifier] Verifier' if $runner eq 'Verifier';
53 if ($runner eq 'Interactive') {
54 say RED
, 'WARNING: Runner::Interactive is experimental', RESET
;
55 prompt_file \
%meta, int => '[Runner::Interactive] Interactive verifier';
58 insert_problem
$id => (
61 statement
=> $statement,
64 generator
=> $generator,
68 ($private ?
(private
=> $private) : ()),
69 (defined $timeout ?
(timeout
=> $timeout) : ()),
70 (defined $olimit ?
(olimit
=> $olimit) : ()));
71 set_problem_meta
$id => \
%meta;
72 PUBLISH genpage
=> $contest ?
"ct/$contest/pb/index.html" : 'pb/index.html';
73 PUBLISH genpage
=> $contest ?
"ct/$contest/pb/$id.html" : "pb/$id.html";
78 GetOptions
( 'file!' => \
$file );
79 my ($id, %values) = @ARGV;
80 %values = map { $_ => scalar read_file
$values{$_} } keys %values if $file;
81 edit_problem
$id => %values;
82 PUBLISH genpage
=> 'pb/index.html';
83 PUBLISH genpage
=> "pb/$id.html";
93 PUBLISH genpage
=> $contest ?
"ct/$contest/pb/index.html" : 'pb/index.html';
97 local $_ = shift or goto &cmd_list
;
100 ##################################################
102 GetOptions
( 'contest=s' => \
$contest );
103 local $Gruntmaster::Data
::contest
= $contest;
104 my $cmd = 'cmd_' . shift;
105 cmd_help
unless exists $main::{$cmd};
107 $cmd->(@ARGV) if exists $main::{$cmd};
116 gruntmaster-problem - shell interface to Gruntmaster 6000 problems
120 gruntmaster-problem [--contest=mycontest] add problem_id
121 gruntmaster-problem [--contest=mycontest] list
122 gruntmaster-problem [--contest=mycontest] rm problem_id
123 gruntmaster-problem [--contest=mycontest] show problem_id
124 gruntmaster-problem [--contest=mycontest] set [--file] problem_id key value
128 gruntmaster-problem is a tool for managing problems.
130 Select the contest with the optional argument I<--contest>.
136 Prints the list of problems in the selected contest.
140 Prints detailed information about problem I<id>.
144 Adds a new problem with id I<id>.
148 Removes the problem with id I<id>.
150 =item B<set> I<id> I<key> I<value>
152 Sets the I<key> configuration option of problem I<id> to I<value>.
154 =item B<set> --file I<id> I<key> I<file>
156 Sets the I<key> configuration option of problem I<id> to the contents of the file I<file>.
162 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
164 =head1 COPYRIGHT AND LICENSE
166 Copyright (C) 2014 by Marius Gavrilescu
168 This library is free software: you can redistribute it and/or modify
169 it under the terms of the GNU Affero General Public License as published by
170 the Free Software Foundation, either version 3 of the License, or
171 (at your option) any later version.
This page took 0.02941 seconds and 4 git commands to generate.