« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/RemoveLabel.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Firewall/Cmd/List.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::Server::Cmd::Describe; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Show server details | ||||||||||||||||||||||||||||
| 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 server describe <id> [options]'; | ||||||||||||||||||||||||||
|
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=8 SCAR=22.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud server describe <id>\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||
| 17 | 1 | my $cloud = $main->cloud; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | my $server = $cloud->servers->get($id); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | print encode_json($server->data), "\n"; | |||||||||||||||||||||||||||
| 23 | 0 | return; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | printf "ID: %s\n", $server->id; | |||||||||||||||||||||||||||
| 27 | 1 | printf "Name: %s\n", $server->name; | |||||||||||||||||||||||||||
| 28 | 1 | printf "Status: %s\n", $server->status; | |||||||||||||||||||||||||||
| 29 | 1 | printf "Type: %s\n", $server->server_type; | |||||||||||||||||||||||||||
| 30 | 1 | printf "Datacenter: %s\n", $server->datacenter; | |||||||||||||||||||||||||||
| 31 | 1 | ▶ | printf "IPv4: %s\n", $server->ipv4 // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$server->ipv4 // "-"
MC/DC0%0/1
$server->ipv4 // "-"
$server->ipv4
Truth table50%1/2
A
A= $server->ipv4
| |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | printf "IPv6: %s\n", $server->ipv6 // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$server->ipv6 // "-"
MC/DC0%0/1
$server->ipv6 // "-"
$server->ipv6
Truth table50%1/2
A
A= $server->ipv6
| |||||||||||||||||||||||||||||
| 33 | 1 | printf "Created: %s\n", $server->created; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | my $labels = $server->labels; | |||||||||||||||||||||||||||
| 36 | 1 | ▶ | if ($labels && %$labels) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$labels and %$labels
MC/DC0%0/2
$labels and %$labels
$labels
%$labels
Truth table33%1/3
A and B
A= $labelsB= %$labels
| |||||||||||||||||||||||||||||
| 37 | 1 | print "Labels:\n"; | |||||||||||||||||||||||||||
| 38 | 1 | for my $k (sort keys %$labels) { | |||||||||||||||||||||||||||
| 39 | 2 | printf " %s: %s\n", $k, $labels->{$k}; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | 1; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||