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

filter: Statementstmt 0.0% 0 / 20 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 27 CC 1 SCAR 6.9
CC
1
Cov
0%
execute
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package WWW::Hetzner::CLI::Cmd::Volume::Cmd::Attach;
2 # ABSTRACT: Attach a volume to a server
3  
4 our $VERSION = '0.100';
5  
6 use Moo;
7 use MooX::Cmd;
8 use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl volume attach <volume-id> --server <server-id>';
9  
10 option server => (
11 is => 'ro',
12 format => 'i',
13 required => 1,
14 doc => 'Server ID to attach to',
15 );
16  
17 option automount => (
18 is => 'ro',
19 doc => 'Automount volume after attach',
20 default => 0,
21 );
22  
23 sub execute {
24 my ($self, $args, $chain) = @_;
25 my $id = $args->[0] or die "Usage: hcloud.pl volume attach <volume-id> --server <server-id>\n";
26  
27 my $main = $chain->[0];
28 my $cloud = $main->cloud;
29  
30 print "Attaching volume $id to server ", $self->server, "...\n";
31 $cloud->volumes->attach($id, $self->server, automount => $self->automount);
32 print "Volume attached.\n";
33 }
34  
35 1;
36  
37 __END__