| 1 | package CPAN::Mini::Inject::REST::Client::Command::all_dists; | ||
| 2 | |||
| 3 | use 5.010; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | use base 'CPAN::Mini::Inject::REST::Client::Command'; | ||
| 7 | |||
| 8 | |||
| 9 | #--Command usage---------------------------------------------------------------- | ||
| 10 | |||
| 11 | sub usage_desc { | ||
| 12 | return "all_dists %o"; | ||
| 13 | } | ||
| 14 | |||
| 15 | sub abstract { | ||
| 16 | return "Lists all distributions added to the repository"; | ||
| 17 | } | ||
| 18 | |||
| 19 | sub description { | ||
| 20 | return "Lists all distributions added to the repository"; | ||
| 21 | } | ||
| 22 | |||
| 23 | |||
| 24 | #--Command specific options----------------------------------------------------- | ||
| 25 | |||
| 26 | sub options { | ||
| 27 | my ($class, $app) = @_; | ||
| 28 | |||
| 29 | return undef; | ||
| 30 | } | ||
| 31 | |||
| 32 | |||
| 33 | #--Command execute method------------------------------------------------------- | ||
| 34 | |||
| 35 | sub execute { | ||
| 36 | my ($self, $opt, $args) = @_; | ||
| 37 | |||
| 38 | my ($code, $result) = $self->api($opt)->get("all_dists"); | ||
| 39 | |||
| 40 | given ($code) { | ||
| 41 | when (200) { | ||
| 42 | say "Distributions:"; | ||
| 43 | say " $_" foreach @{$result->{dists}}; | ||
| 44 | } | ||
| 45 | when (204) { | ||
| 46 | die "No distributions have been added\n" | ||
| 47 | } | ||
| 48 | default { | ||
| 49 | die "Cannot retrieve distribution info - unknown error!\n"; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | #------------------------------------------------------------------------------- | ||
| 56 | |||
| 57 | 1; |