lib/WWW/Hetzner/CLI/Cmd/FloatingIp/Cmd/Create.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 30 CC 3 SCAR 19.5
CC
3
Cov
0%
execute
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 7.0
1 package WWW::Hetzner::CLI::Cmd::FloatingIp::Cmd::Create;
2 # ABSTRACT: Create a floating IP
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 floating-ip create --type <ipv4|ipv6> --home-location <location>';
9  
10 option type => (
11 is => 'ro',
12 format => 's',
13 required => 1,
14 doc => 'IP type: ipv4 or ipv6',
15 );
16  
17 option 'home_location' => (
18 is => 'ro',
19 format => 's',
20 required => 1,
21 long_doc => 'home-location',
22 doc => 'Home location (e.g. fsn1, nbg1)',
23 );
24  
25 option name => (
26 is => 'ro',
27 format => 's',
28 doc => 'Floating IP name',
29 );
30  
31 option description => (
32 is => 'ro',
33 format => 's',
34 doc => 'Description',
35 );
36  
37 sub execute {
38 my ($self, $args, $chain) = @_;
39  
40 my $main = $chain->[0];
41 my $cloud = $main->cloud;
42  
43 print "Creating floating IP...\n";
44 my $fip = $cloud->floating_ips->create(
45 type => $self->type,
46 home_location => $self->home_location,
47 ($self->name ? (name => $self->name) : ()),
48 ($self->description ? (description => $self->description) : ()),
49 );
50 print "Floating IP created with ID ", $fip->id, " (", $fip->ip, ")\n";
51 }
52  
53 1;
54  
55 __END__