Ordo/Command/Cd.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 51 CC 2 SCAR 9.8
CC
2
Cov
0%
execute
6.0
name
2.0
summary
2.0
CRAP 2.7
1 package App::Ordo::Command::Cd;
2 use Moo;
3 extends 'App::Ordo::Command::Base';
4 use feature qw(say);
5 use utf8;
6 use open ':std', ':utf8';
7 use App::Ordo qw($CURRENT_PATH);
8 use Term::ANSIColor qw(colored);
9 #use Text::Table::Tiny 1.02 qw(generate_table);
10  
11 sub name { "cd" }
12 sub summary { "Change current cluster" }
13 sub usage { "<path>" }
14  
15 # No options — pure positional
16 sub option_spec { {} }
17  
18 sub execute {
19 my ($self, $opt, $target) = @_;
20  
21 my $res = $self->api->call('change_cluster', { name => $target });
22  
23 if ($res->{success}) {
24 $App::Ordo::CURRENT_PATH = $res->{path};
25 } else {
26 say colored(["bold red"], "Cannot cd to '$target': " . ($res->{message} || 'not found'));
27 }
28 }
29  
30 1;