« lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/Describe.pm
↑ Summary
lib/WWW/Hetzner/Robot/API/Keys.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Folders; | ||||||||||
| 2 | # ABSTRACT: List Storage Box folders | ||||||||||
| 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 storage-box folders [--path <path>] <storage-box>'; | ||||||||
|
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 | |||||||||||
| 12 | 1 | option path => ( | |||||||||
| 13 | is => 'ro', | ||||||||||
| 14 | format => 's', | ||||||||||
| 15 | doc => 'Folder path (default /)', | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=6 SCAR=19.9
Pod
undocumented
| |||||||||||
| 19 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 20 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl storage-box folders <storage-box>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 1 | my $main = $chain->[0]; | |||||||||
| 22 | |||||||||||
| 23 | 1 | my %params; | |||||||||
| 24 | 1 | ▶ | $params{path} = $self->path if defined $self->path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | 1 | my $folders = $main->storage->storage_boxes->folders($id, %params); | |||||||||
| 27 | |||||||||||
| 28 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | print encode_json($folders), "\n"; | |||||||||
| 30 | 0 | return; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 1 | ▶ | if (!@$folders) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | print "No folders found.\n"; | |||||||||
| 35 | 0 | return; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 1 | printf "%s\n", 'PATH'; | |||||||||
| 39 | 1 | print '-' x 60, "\n"; | |||||||||
| 40 | 1 | for my $folder (@$folders) { | |||||||||
| 41 | 2 | printf "%s\n", $folder; | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 1 | 1; | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||