| 1 | # Example: lib/App/Ordo/Command/Job/Hold.pm | ||
| 2 | package App::Ordo::Command::Job::Hold; | ||
| 3 | use feature qw(say); | ||
| 4 | use Moo; | ||
| 5 | extends 'App::Ordo::Command::Base'; | ||
| 6 | use Term::ANSIColor qw(colored); | ||
| 7 | |||
| 8 | sub name { "job hold" } | ||
| 9 | sub summary { "Pause a job from running" } | ||
| 10 | sub usage { "<path/name>" } | ||
| 11 | |||
| 12 | sub option_spec { {} } | ||
| 13 | |||
| 14 | sub execute { | ||
| 15 | my ($self, $opt, $name) = @_; | ||
| 16 | unless ($name) { | ||
| 17 | say colored(["bold red"], "Usage: job hold <path/name>"); | ||
| 18 | return; | ||
| 19 | } | ||
| 20 | |||
| 21 | my $res = $self->api->call('hold_job', { name => $name }); | ||
| 22 | |||
| 23 | $res->{success} | ||
| 24 | ? say colored(["bold yellow"], "Job '$name' held") | ||
| 25 | : say colored(["bold red"], "Failed: " . ($res->{message} || 'error')); | ||
| 26 | } | ||
| 27 | |||
| 28 | 1; |