| 1 | # ABSTRACT: Print a claim name derived from the checkout directory | ||
| 2 | |||
| 3 | package App::karr::Cmd::AgentName; | ||
| 4 | our $VERSION = '0.602'; | ||
| 5 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use MooX::Cmd; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use MooX::Options ( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | usage_string => 'USAGE: karr agentname [--unique]', | |
| 9 | 1 | ); | |
| 10 | 0 | ▶ | use App::karr::AgentName qw( agent_name ); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 11 | use App::karr::Role::CliArgs; | ||
| 12 | use App::karr::Role::ExitCodes; | ||
| 13 | use App::karr::Role::Output; | ||
| 14 | |||
| 15 | # Unknown option / bad option value exits 2, not 1 (ADR 0002 exit-code | ||
| 16 | # contract). This board-less command has no BoardDiscovery to inherit it from. | ||
| 17 | with 'App::karr::Role::CliArgs'; | ||
| 18 | with 'App::karr::Role::ExitCodes'; | ||
| 19 | with 'App::karr::Role::Output'; | ||
| 20 | |||
| 21 | |||
| 22 | option unique => ( | ||
| 23 | is => 'ro', | ||
| 24 | doc => 'Append a short random suffix, to tell apart agents in one directory', | ||
| 25 | ); | ||
| 26 | |||
| 27 | sub execute { | ||
| 28 | my ($self, $args_ref, $chain_ref) = @_; | ||
| 29 | |||
| 30 | my $name = agent_name( unique => $self->unique ); | ||
| 31 | if ($self->json) { | ||
| 32 | $self->print_json( { name => $name } ); | ||
| 33 | } else { | ||
| 34 | print "$name\n"; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; | ||
| 39 | |||
| 40 | __END__ | ||