]>
iEval git - gruntmaster-data.git/blob - lib/Gruntmaster/App/Command/Edit.pm
7552a936959bc0db5ba8f1e4d2ceeb82d2d5934b
1 package Gruntmaster
::App
::Command
::Edit
;
6 our $VERSION = '6000.001';
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 use Gruntmaster
::App
::Command
::Set
;
14 BEGIN { *PAGES
= *Gruntmaster
::App
::Command
::Set
::PAGES
}
16 sub usage_desc
{ '%c [-cjpu] edit id column' }
19 my ($self, $opt, $args) = @_;
21 $self->usage_error('No table selected') unless $self->app->table;
22 $self->usage_error('Wrong number of arguments') if @args != 2;
26 my ($self, $opt, $args) = @_;
27 my ($obj, $col) = @
$args;
28 my ($fh, $file) = tempfile
'gruntmaster-problem-editXXXX', TMPDIR
=> 1, UNLINK
=> 1;
29 write_file
$fh, db
->select($self->app->table, $col, {id
=> $obj})->flat;
31 my $editor = $ENV{EDITOR
} // 'editor';
32 system $editor, $file;
33 db
->update($self->app->table, {$col => scalar read_file
$file}, {id
=> $obj});
34 purge PAGES
->{$self->app->table}.$_ for '', $obj;
44 Gruntmaster::App::Command::Edit - edit a property of an object
49 gm -p edit aplusb level
50 gm -c edit test_ct description
51 gm -j edit 100 result_text
55 The get command takes two arguments: an object id and a property name,
56 and opens an editor with the value of that property. Upon exiting the
57 editor, the property is set to the contents of the file.
61 The editor is taken from the EDITOR environment variable. If this
62 variable is unset, the program F<editor> is executed instead.
70 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
72 =head1 COPYRIGHT AND LICENSE
74 Copyright (C) 2014-2016 by Marius Gavrilescu
76 This library is free software; you can redistribute it and/or modify
77 it under the same terms as Perl itself, either Perl version 5.20.1 or,
78 at your option, any later version of Perl 5 you may have available.
This page took 0.053101 seconds and 4 git commands to generate.