Ordo/Command/Cal/Attach.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 53 CC 3 SCAR 16.1
CC
3
Cov
0%
execute
12.0
name
2.0
summary
2.0
CRAP 5.0
1 package App::Ordo::Command::Cal::Attach;
2 use Moo;
3 use Term::ANSIColor qw(colored);
4 use feature qw(say);
5 extends 'App::Ordo::Command::Base';
6  
7 sub name { "cal attach" }
8 sub summary { "Attach a calendar to a cluster" }
9 sub usage { "<calendar> <cluster-path>" }
10  
11 sub option_spec { {} }
12  
13 sub execute {
14 my ($self, $opt, $cal_name, $cluster_path) = @_;
15  
16 unless ($cal_name && $cluster_path) {
17 say colored(["bold red"], "Usage: cal attach <calendar> <cluster-path>");
18 return;
19 }
20  
21 my $res = $self->api->call('update_cluster', {
22 name => $cluster_path,
23 cal => $cal_name, # server accepts 'cal' => name
24 });
25  
26 if ($res->{success}) {
27 say colored(["bold green"], "Calendar '$cal_name' attached to cluster '$cluster_path'");
28 } else {
29 say colored(["bold red"], "Failed: " . ($res->{message} || 'not found'));
30 }
31 }
32  
33 1;