| 1 | package WWW::Hetzner::CLI::Cmd::Network::Cmd::List; | ||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: List networks | ||||||||||||||||||||||||||||||||
| 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 network list'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use JSON::MaybeXS qw(encode_json); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=7 SCAR=22.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 12 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||||||
| 15 | 1 | my $cloud = $main->cloud; | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 1 | my $networks = $cloud->networks->list_all; | |||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 20 | 0 | print encode_json([ map { $_->data } @$networks ]), "\n"; | |||||||||||||||||||||||||||||||
| 21 | 0 | return; | |||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | if (!@$networks) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 25 | 0 | print "No networks found.\n"; | |||||||||||||||||||||||||||||||
| 26 | 0 | return; | |||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 1 | printf "%-8s %-25s %-18s %-10s\n", 'ID', 'NAME', 'IP_RANGE', 'SERVERS'; | |||||||||||||||||||||||||||||||
| 30 | 1 | printf "%-8s %-25s %-18s %-10s\n", '-' x 8, '-' x 25, '-' x 18, '-' x 10; | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 1 | for my $n (@$networks) { | |||||||||||||||||||||||||||||||
| 33 | printf "%-8s %-25s %-18s %-10d\n", | ||||||||||||||||||||||||||||||||
| 34 | $n->id, | ||||||||||||||||||||||||||||||||
| 35 | $n->name // '-', | ||||||||||||||||||||||||||||||||
| 36 | $n->ip_range // '-', | ||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | scalar(@{ $n->servers // [] }); | ||||||||||||||||||||||||||||||
|
Condition50%3/6
$n->name // "-"
$n->ip_range // "-"
$n->servers // []
MC/DC0%0/1
$n->name // "-"
$n->name
MC/DC0%0/1
$n->ip_range // "-"
$n->ip_range
MC/DC0%0/1
$n->servers // []
$n->servers
Truth table50%1/2
A
A= $n->name
Truth table50%1/2
A
A= $n->ip_range
Truth table50%1/2
A
A= $n->servers
| |||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 1 | 1; | |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||||||