lib/WWW/Hetzner/CLI/Cmd/Volume/Cmd/Attach.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 90.3% 28 / 31 CC 3 SCAR 7.0
CC
3
Cov
92%
execute
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« lib/WWW/Hetzner/CLI/Cmd/Network/Cmd/AddRoute.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/LoadBalancer/Cmd/AddService.pm »
1 package WWW::Hetzner::CLI::Cmd::Volume::Cmd::Attach;
2 # ABSTRACT: Attach a volume to a server
3  
4 1 our $VERSION = '0.102';
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl volume attach <volume-id> --server <server-id>';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 with 'WWW::Hetzner::CLI::Role::WaitsForAction';
10  
11 1 option server => (
12 is => 'ro',
13 format => 'i',
14 required => 1,
15 doc => 'Server ID to attach to',
16 );
17  
18 1 option automount => (
19 is => 'ro',
20 doc => 'Automount volume after attach',
21 default => 0,
22 );
23  
24 1 ▶sub execute {
Subroutine execute: called CC=3 SCAR=11.1
Pod undocumented
25 1 my ($self, $args, $chain) = @_;
26 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl volume attach <volume-id> --server <server-id>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl volume attach <volume-id> --server <server-id>\n" 1 0 1
27  
28 1 my $main = $chain->[0];
29 1 my $cloud = $main->cloud;
30  
31 1 print "Attaching volume $id to server ", $self->server, "...\n";
32 1 my $action = $cloud->volumes->attach($id, $self->server, automount => $self->automount);
33 1 $self->handle_action($action);
34 1 ▶ print $self->no_wait ? "Volume attach requested.\n" : "Volume attached.\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->no_wait ? : 1 0 1
35 }
36  
37 1 1;
38  
39 __END__
« lib/WWW/Hetzner/CLI/Cmd/Network/Cmd/AddRoute.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/LoadBalancer/Cmd/AddService.pm »