| 1 | # ABSTRACT: Disable automated agent runs on this board | ||
| 2 | |||
| 3 | package App::karr::Cmd::Disable; | ||
| 4 | our $VERSION = '0.602'; | ||
| 5 | use Moo; | ||
| 6 | use MooX::Cmd; | ||
| 7 | use MooX::Options ( | ||
| 8 | usage_string => 'USAGE: karr disable [--reason "why"] [--json]', | ||
| 9 | ); | ||
| 10 | use App::karr::Role::BoardAccess; | ||
| 11 | use App::karr::Role::Output; | ||
| 12 | |||
| 13 | with 'App::karr::Role::BoardAccess', 'App::karr::Role::Output'; | ||
| 14 | |||
| 15 | |||
| 16 | option reason => ( | ||
| 17 | is => 'ro', | ||
| 18 | format => 's', | ||
| 19 | doc => 'Why this board is disabled (stored as foundation.reason)', | ||
| 20 | ); | ||
| 21 | |||
| 22 | sub execute { | ||
| 23 | my ($self, $args_ref, $chain_ref) = @_; | ||
| 24 | |||
| 25 | $self->check_positional_args($args_ref, 0); | ||
| 26 | |||
| 27 | $self->sync_before; | ||
| 28 | $self->require_board; | ||
| 29 | $self->store->set_foundation_enabled( 0, $self->reason ); | ||
| 30 | $self->sync_after; | ||
| 31 | |||
| 32 | my $reason = $self->store->foundation_reason; | ||
| 33 | |||
| 34 | if ($self->json) { | ||
| 35 | $self->print_json({ | ||
| 36 | foundation => { | ||
| 37 | enabled => 0, | ||
| 38 | ( defined $reason ? ( reason => $reason ) : () ), | ||
| 39 | }, | ||
| 40 | }); | ||
| 41 | return; | ||
| 42 | } | ||
| 43 | |||
| 44 | print "Board disabled for automated agent runs (karr-foundation).\n"; | ||
| 45 | printf " Reason: %s\n", $reason if defined $reason; | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; | ||
| 49 | |||
| 50 | __END__ |