« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Update.pm
↑ Summary
lib/WWW/Hetzner/Robot/API/Failover.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::Location; | ||||||||||
| 2 | # ABSTRACT: Location 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 location [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=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 12 | 2 | my ($self, $args, $chain) = @_; | |||||||||
| 13 | |||||||||||
| 14 | 2 | my $main = $chain->[0]; | |||||||||
| 15 | 2 | my $cloud = $main->cloud; | |||||||||
| 16 | 2 | my $locations = $cloud->locations->list_all; | |||||||||
| 17 | |||||||||||
| 18 | 2 | ▶ | if ($main->output eq 'json') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | print encode_json([ map { $_->data } @$locations ]), "\n"; | |||||||||
| 20 | 1 | return; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 1 | printf "%-10s %-30s %-10s %s\n", 'ID', 'NAME', 'COUNTRY', 'CITY'; | |||||||||
| 24 | 1 | print "-" x 70, "\n"; | |||||||||
| 25 | |||||||||||
| 26 | 1 | for my $l (@$locations) { | |||||||||
| 27 | 3 | printf "%-10s %-30s %-10s %s\n", | |||||||||
| 28 | $l->id, | ||||||||||
| 29 | $l->name, | ||||||||||
| 30 | $l->country, | ||||||||||
| 31 | $l->city; | ||||||||||
| 32 | } | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 2 | 1; | |||||||||
| 36 | |||||||||||
| 37 | __END__ | ||||||||||