]>
iEval git - gruntmaster-data.git/blob - lib/Gruntmaster/App/Command/Edit.pm
24785ab01996e300122fef193fbc39d719938655
1 package Gruntmaster
::App
::Command
::Edit
;
6 our $VERSION = '5999.000_015';
8 use File
::Temp qw
/tempfile/;
9 use File
::Slurp qw
/read_file write_file/;
10 use Gruntmaster
::App
'-command';
11 use Gruntmaster
::Data
;
13 sub usage_desc
{ '%c [-cjpu] edit id column' }
16 my ($self, $opt, $args) = @_;
18 $self->usage_error('No table selected') unless $self->app->table;
19 $self->usage_error('Wrong number of arguments') if @args != 2;
23 my ($self, $opt, $args) = @_;
24 my ($obj, $col) = @
$args;
25 my ($fh, $file) = tempfile
'gruntmaster-problem-editXXXX', TMPDIR
=> 1, UNLINK
=> 1;
26 write_file
$fh, db
->select($self->app->table, $col, {id
=> $obj})->flat;
28 my $editor = $ENV{EDITOR
} // 'editor';
29 system $editor, $file;
30 db
->update($self->app->table, {$col => scalar read_file
$file}, {id
=> $obj});
40 Gruntmaster::App::Command::Edit - edit a property of an object
45 gm -p edit aplusb level
46 gm -c edit test_ct description
47 gm -j edit 100 result_text
51 The get command takes two arguments: an object id and a property name,
52 and opens an editor with the value of that property. Upon exiting the
53 editor, the property is set to the contents of the file.
57 The editor is taken from the EDITOR environment variable. If this
58 variable is unset, the program F<editor> is executed instead.
66 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
68 =head1 COPYRIGHT AND LICENSE
70 Copyright (C) 2014-2015 by Marius Gavrilescu
72 This library is free software; you can redistribute it and/or modify
73 it under the same terms as Perl itself, either Perl version 5.20.1 or,
74 at your option, any later version of Perl 5 you may have available.
This page took 0.051628 seconds and 4 git commands to generate.