| 1 | package WWW::Hetzner::CLI::Cmd::Servertype; | ||||||||||
| 2 | # ABSTRACT: Server type commands | ||||||||||
| 3 | |||||||||||
| 4 | 2 | our $VERSION = '0.102'; | |||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use MooX::Cmd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use MooX::Options usage_string => 'USAGE: hcloud.pl servertype [options]'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use JSON::MaybeXS qw(encode_json); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 12 | 2 | my ($self, $args, $chain) = @_; | |||||||||
| 13 | |||||||||||
| 14 | 2 | my $main = $chain->[0]; | |||||||||
| 15 | 2 | my $cloud = $main->cloud; | |||||||||
| 16 | 2 | my $types = $cloud->server_types->list_all; | |||||||||
| 17 | |||||||||||
| 18 | 2 | ▶ | if ($main->output eq 'json') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | print encode_json([ map { $_->data } @$types ]), "\n"; | |||||||||
| 20 | 1 | return; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 1 | printf "%-10s %-12s %-8s %-10s %-10s %s\n", | |||||||||
| 24 | 'ID', 'NAME', 'CORES', 'MEMORY', 'DISK', 'DEPRECATED'; | ||||||||||
| 25 | 1 | print "-" x 70, "\n"; | |||||||||
| 26 | |||||||||||
| 27 | 1 | for my $t (@$types) { | |||||||||
| 28 | 3 | ▶ | printf "%-10s %-12s %-8s %-10s %-10s %s\n", | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | $t->id, | ||||||||||
| 30 | $t->name, | ||||||||||
| 31 | $t->cores, | ||||||||||
| 32 | $t->memory . ' GB', | ||||||||||
| 33 | $t->disk . ' GB', | ||||||||||
| 34 | $t->deprecated ? 'yes' : '-'; | ||||||||||
| 35 | } | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 2 | 1; | |||||||||
| 39 | |||||||||||
| 40 | __END__ | ||||||||||