| 1 | package Getopt::Kingpin::Command; | ||||||||||
| 2 | 28 | ▶ | use 5.008001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 28 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 28 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 28 | ▶ | use Getopt::Kingpin -base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 28 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 28 | our $VERSION = "0.09"; | |||||||||
| 9 | |||||||||||
| 10 | sub help_short { | ||||||||||
| 11 | 32 | ▶ | my $self = shift; | ||||||||
|
Subroutine
help_short: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 12 | 32 | my @help = ($self->name); | |||||||||
| 13 | |||||||||||
| 14 | 32 | ▶ | if ($self->name eq "help") { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 6 | push @help, "[<command>...]"; | |||||||||
| 16 | } else { | ||||||||||
| 17 | 26 | ▶ | if ($self->flags->count > 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 17 | push @help, "[<flags>]"; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 26 | ▶ | if ($self->commands->count > 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 1 | push @help, "<command>"; | |||||||||
| 23 | 1 | push @help, "[<args> ...]"; | |||||||||
| 24 | } else { | ||||||||||
| 25 | 25 | foreach my $arg ($self->args->get_all) { | |||||||||
| 26 | 21 | push @help, $arg->help_name(1); | |||||||||
| 27 | } | ||||||||||
| 28 | } | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 32 | return join " ", @help; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | sub help { | ||||||||||
| 35 | 17 | ▶ | my $self = shift; | ||||||||
|
Subroutine
help: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 36 | 17 | printf "usage: %s %s\n", $self->parent->name, $self->help_short; | |||||||||
| 37 | 17 | printf "\n"; | |||||||||
| 38 | |||||||||||
| 39 | 17 | ▶ | if ($self->description ne "") { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 16 | printf "%s\n", $self->description; | |||||||||
| 41 | 16 | printf "\n"; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 17 | printf "%s\n", $self->flags->help; | |||||||||
| 45 | |||||||||||
| 46 | 17 | ▶ | if ($self->args->count > 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 10 | printf "%s\n", $self->args->help; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 17 | ▶ | if ($self->commands->count > 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 1 | printf "Subcommands:\n"; | |||||||||
| 52 | 1 | foreach my $sub ($self->commands->get_all) { | |||||||||
| 53 | 2 | ▶ | next if $sub->name eq "help"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 1 | printf " %s %s\n", $sub->parent->name, $sub->name; | |||||||||
| 55 | 1 | printf " %s\n", $sub->description; | |||||||||
| 56 | 1 | printf "\n"; | |||||||||
| 57 | } | ||||||||||
| 58 | } | ||||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 28 | 1; | |||||||||
| 62 | __END__ | ||||||||||