Add show_job and show_user to gm command
[gruntmaster-data.git] / lib / Gruntmaster / App / Command / Set.pm
CommitLineData
92f74061
MG
1package Gruntmaster::App::Command::Set;
2
3use 5.014000;
4use warnings;
5
6our $VERSION = '5999.000_004';
7
8use Gruntmaster::App '-command';
9use Gruntmaster::Data;
10
11use File::Slurp qw/read_file/;
12
13sub opt_spec {
14 ['file!', 'Use the contents of a file as value'],
15}
16
17sub usage_desc { "%c [-cjpu] set id column value [column value ...]\n%c [-cjpu] set --file id column filename [column filename ...]" }
18
19sub validate_args {
20 my ($self, $opt, $args) = @_;
21 my @args = @$args;
22 $self->usage_error('No table selected') unless $self->app->table;
23 $self->usage_error('Not enough arguments provided') if @args < 3;
24 $self->usage_error('The number of arguments must be odd') unless @args % 2;
25}
26
27sub execute {
28 my ($self, $opt, $args) = @_;
29 my ($id, %values) = @$args;
30 %values = map { $_ => scalar read_file $values{$_} } keys %values if $opt->{file};
31 db->update($self->app->table, \%values, {id => $id});
32}
33
341;
35__END__
This page took 0.01131 seconds and 4 git commands to generate.