| 1 | package Log::Munger::App; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use App::Cmd::Setup -app; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | Log::Munger::App - The App::Cmd application behind the log_munger command. | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 16 | our $VERSION = '0.0.1'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # The options every subcommand accepts, as App::Cmd wants them. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # Takes the args App::Cmd hands a global_opt_spec. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # Returns a list of App::Cmd option tuples, currently help and version. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # version deliberately has no -v alias: a global -v would swallow the short | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # form of subcommand options such as test_all's --verbose and dump_rule_file's | ||||||||||||||||||||||||||||||||||||||||||
| 24 | # --var. A leading -v still prints the version via prepare_command below. | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 16 | ▶ | sub global_opt_spec { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
global_opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 16 | return ( [ 'help|h' => "This usage screen." ], [ 'version' => "Print the version." ], ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | # The App::Cmd hook that turns the raw command line into a command object. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # Overridden so a leading --version or -v dispatches to the built-in version | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # command; App::Cmd parses the global option but nothing would otherwise act | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # on it, leaving the flag to fall through to the usage screen. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # Args: | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # - @args :: The raw command line args, as App::Cmd passes them. | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # Returns whatever App::Cmd's prepare_command returns. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 16 | ▶ | sub prepare_command { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_command: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 16 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 16 | ▶ | if ( defined( $args[0] ) && ( $args[0] eq '--version' || $args[0] eq '-v' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $args[0] and $args[0] eq "--version" || $args[0] eq "-v"
$args[0] eq "--version" or $args[0] eq "-v"
MC/DC0%0/3
defined $args[0] and $args[0] eq "--version" || $args[0] eq "-v"
defined $args[0]
$args[0] eq "--version"
$args[0] eq "-v"
Truth table25%1/4
A and B or C
A= defined $args[0]B= $args[0] eq "--version"C= $args[0] eq "-v"
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return $self->SUPER::prepare_command('version'); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 16 | return $self->SUPER::prepare_command(@args); | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||