projects
/
gruntmaster-data.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
78c794d
)
Add an edit command to gruntmaster-problem
author
Marius Gavrilescu
<marius@ieval.ro>
Fri, 6 Feb 2015 18:23:04 +0000
(20:23 +0200)
committer
Marius Gavrilescu
<marius@ieval.ro>
Fri, 6 Feb 2015 18:23:04 +0000
(20:23 +0200)
gruntmaster-problem
patch
|
blob
|
blame
|
history
diff --git
a/gruntmaster-problem
b/gruntmaster-problem
index 819b7ef0a4c3f97ed91f282fc92d35f2ef244890..7e979cdc05164e6c8c4788efb6d19756e7ada04b 100755
(executable)
--- a/
gruntmaster-problem
+++ b/
gruntmaster-problem
@@
-3,8
+3,10
@@
use v5.14;
use Gruntmaster::Data;
use Gruntmaster::Data;
+use File::Temp qw/tempfile/;
+
use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ];
use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ];
-use File::Slurp qw/read_file/;
+use File::Slurp qw/read_file
write_file
/;
use JSON qw/encode_json/;
use Term::ANSIColor qw/RED RESET/;
use Getopt::Long qw/:config require_order/;
use JSON qw/encode_json/;
use Term::ANSIColor qw/RED RESET/;
use Getopt::Long qw/:config require_order/;
@@
-103,6
+105,16
@@
sub cmd_get{
say $db->problem($id)->get_column($col)
}
say $db->problem($id)->get_column($col)
}
+sub cmd_edit{
+ my ($id, $col) = @_;
+ my ($fh, $file) = tempfile 'gruntmaster-problem-editXXXX', TMPDIR => 1, UNLINK => 1;
+ write_file $fh, $db->problem($id)->get_column($col);
+ close $fh;
+ my $editor = $ENV{EDITOR} // 'editor';
+ system $editor, $file;
+ $db->problem($id)->update({$col => read_file $file});
+}
+
sub cmd_list{
local $, = "\n";
say map {$_->id} $db->problems->all
sub cmd_list{
local $, = "\n";
say map {$_->id} $db->problems->all
@@
-155,6
+167,7
@@
gruntmaster-problem - shell interface to Gruntmaster 6000 problems
gruntmaster-problem show problem_id
gruntmaster-problem set [--file] problem_id key value
gruntmaster-problem get problem_id key
gruntmaster-problem show problem_id
gruntmaster-problem set [--file] problem_id key value
gruntmaster-problem get problem_id key
+ gruntmaster-problem edit problem_id key
=head1 DESCRIPTION
=head1 DESCRIPTION
@@
-186,6
+199,10
@@
Sets the I<key> configuration option of problem I<id> to I<value>.
Get the value of the I<key> configuration option of problem I<id>
Get the value of the I<key> configuration option of problem I<id>
+=item B<edit> I<id> I<key>
+
+Opens an editor with the value of the I<key> configuration option. After the editor exits, the option is updated to the value of the file.
+
=item B<set> --file I<id> I<key> I<file>
Sets the I<key> configuration option of problem I<id> to the contents of the file I<file>.
=item B<set> --file I<id> I<key> I<file>
Sets the I<key> configuration option of problem I<id> to the contents of the file I<file>.
This page took
0.010937 seconds
and
4
git commands to generate.