]> iEval git - gruntmaster-page.git/blame - gruntmaster-problem
Remove some languages
[gruntmaster-page.git] / gruntmaster-problem
CommitLineData
4f3ef247
MG
1#!/usr/bin/perl -w
2use v5.14;
3
4use Gruntmaster::Data qw/insert_problem remove_problem set_problem_meta problems/;
5
6use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ];
7use File::Slurp qw/read_file/;
8use Term::ANSIColor qw/RED RESET/;
9
10##################################################
11
12sub cmd_help{
13 exec perldoc => $0
14}
15
16sub prompt_file{
17 my ($meta, $name, $prefix) = @_;
18 my $filename = prompt '$prefix filename', -complete => 'filenames';
19 $meta->{files}{$name}{content} = read_file $filename;
20 $meta->{files}{$name}{format} = prompt '$prefix format', -menu => [keys Gruntmaster::Page::Log::FORMAT_EXTENSION()];
21 $meta->{files}{$name}{name} = prompt "$prefix filename [$filename]", -default => $filename;
22
23}
24
25sub cmd_add{
26 my $id = shift;
27 my $contest = prompt 'Contest';
28 local $Gruntmaster::Data::contest = $contest if $contest;
29 my $name = prompt 'Problem name';
1bbb3698 30 my $level = prompt 'Problem level', -menu => "beginner\neasy\nmedium\nhard";
4f3ef247
MG
31 my $statement = read_file prompt 'File with problem statement', -complete => 'filenames';
32 my %meta;
33 $meta{generator} = prompt 'Generator', -menu => "File\nRun\nUndef";
34 $meta{runner} = prompt 'Runner', -menu => "File\nVerifier\nInteractive";
35 $meta{judge} = prompt 'Judge', -menu => "Absolute\nPoints";
36 $meta{testcnt} = prompt 'Test count', '-i';
37
1bbb3698
MG
38 $meta{timeout} = prompt 'Time limit (seconds)', '-n';
39 delete $meta{timeout} unless $meta{timeout};
40 $meta{olimit} = prompt 'Output limit (bytes)', '-i';
41 delete $meta{olimit} unless $meta{olimit};
42 say 'Memory limits are broken, so I won\'t ask you for one';
43
4f3ef247
MG
44 if ($meta{generator} eq 'File') {
45 my $prefix = prompt '[Generator::File] Input file prefix';
46 $meta{infile}[$_ - 1] = read_file "$prefix$_.in" for 1 .. $meta{testcnt};
47 }
48
49 prompt_file \%meta, gen => '[Generator::Run] Generator' if $meta{generator} eq 'Run';
50
51 if ($meta{runner} eq 'File') {
52 my $prefix = prompt '[Runner::File] Output file prefix';
53 $meta{okfile}[$_ - 1] = read_file "$prefix$_.ok" for 1 .. $meta{testcnt};
54 $meta{tests}[$_ - 1] = prompt "[Runner::File] Score for test ${_} [10]", '-i', -default => 10 for 1 .. $meta{testcnt};
55 }
56
57 prompt_file \%meta, ver => '[Runner::Verifier] Verifier' if $meta{runner} eq 'Verifier';
58
59 if ($meta{runner} eq 'Interactive') {
60 say RED, 'WARNING: Runner::Interactive is experimental', RESET;
61 prompt_file int => '[Runner::Interactive] Interactive verifier';
62 }
63
64 insert_problem $id => name => $name, level => $level, statement => $statement;
65 set_problem_meta $id => \%meta;
66}
67
68sub cmd_list{
69 my $contest = shift;
70 local $Gruntmaster::Data::contest = $contest if $contest;
71 print problems;
72}
73
74sub cmd_rm{
75 remove_problem shift
76}
77
78sub cmd_show{
79 local $_ = shift or goto &cmd_list;
80}
81
82##################################################
83
84no strict 'refs';
85my $cmd = 'cmd_' . shift;
86cmd_help unless exists $main::{$cmd};
87$cmd->(@ARGV) if exists $main::{$cmd};
88
891;
90__END__
91
92=encoding utf-8
93
94=head1 NAME
95
96gruntmaster-problem - shell interface to Gruntmaster 6000 problems
97
98=head1 SYNOPSIS
99
100 gruntmaster-problem add problem_id
101 gruntmaster-problem list
102 gruntmaster-problem rm problem_id
103 gruntmaster-problem show problem_id
104
105
106=head1 DESCRIPTION
107
108
109
110=cut
This page took 0.031352 seconds and 4 git commands to generate.