]>
iEval git - gruntmaster-data.git/blob - lib/Gruntmaster/App/Command/Set.pm
e1beade0eb7b1bfaf285cb6a0504b3788fd0e0bf
1 package Gruntmaster
::App
::Command
::Set
;
6 our $VERSION = '6000.001';
8 use Gruntmaster
::App
'-command';
11 use File
::Slurp qw
/read_file/;
13 use constant PAGES
=> {
21 ['file!', 'Use the contents of a file as value']
24 sub usage_desc
{ "%c [-cjpu] set id column value [column value ...]\n%c [-cjpu] set --file id column filename [column filename ...]" }
27 my ($self, $opt, $args) = @_;
29 $self->usage_error('No table selected') unless $self->app->table;
30 $self->usage_error('Not enough arguments provided') if @args < 3;
31 $self->usage_error('The number of arguments must be odd') unless @args % 2;
35 my ($self, $opt, $args) = @_;
36 my ($id, %values) = @
$args;
37 %values = map { $_ => scalar read_file
$values{$_} } keys %values if $opt->{file
};
38 db
->update($self->app->table, \
%values, {id
=> $id});
39 purge PAGES
->{$self->app->table}.$_ for '', $id;
49 Gruntmaster::App::Command::Set - set a property of an object
53 gm -u set MGV name 'Marius Gavrilescu'
54 gm -p set aplusb level beginner
55 gm -c set test_ct 'This is a <b>test</b> contest.<br>Nothing to see here'
56 gm -j set 100 result_text Accepted
60 The set command takes three arguments: an object id, a property name,
61 and a value. It sets the given property of the given object to the
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.053164 seconds and 4 git commands to generate.