blib/lib/App/RecordStream/Operation/help.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 52 CC 2 SCAR 10.0
CC
2
Cov
0%
init
6.0
usage
2.0
init_help
2.0
CRAP 2.7
1 use strict;
2 use warnings;
3  
4 package App::RecordStream::Operation::help;
5 use base qw(App::RecordStream::Operation);
6  
7 use Carp qw< croak >;
8  
9 sub usage {
10 my $this = shift;
11 my $args_string = $this->options_string([]);
12  
13 return <<USAGE;
14 Usage: recs help <command-name>
15 recs help <option>
16 __FORMAT_TEXT__
17 Show help for the given command or options. Equivalent to using `recs
18 command --help` and friends.
19 __FORMAT_TEXT__
20  
21 Arguments:
22 $args_string
23  
24 Examples:
25 Show help for fromcsv command
26 recs help fromcsv
27 Show help for code snippets
28 recs help --snippet
29 USAGE
30 }
31  
32 sub init_help {
33 my $this = shift;
34 $this->SUPER::init_help(@_);
35  
36 # Make all help types available, sans the redundant "help-" prefix
37 for my $type (keys %{ $this->{'HELP_TYPES'} }) {
38 $this->use_help_type($type);
39 $this->{'HELP_TYPES'}{$type}{OPTION_NAME} ||= $type;
40 }
41 }
42  
43 sub init {
44 my $this = shift;
45 my $args = shift;
46 $this->parse_options($args, {});
47  
48 my $op = shift @$args;
49 if ($op) {
50 # Command help
51 local @ARGV = ("--help");
52 App::RecordStream::Operation::main("recs-$op");
53 } else {
54 # Option help
55 $this->_set_wants_help(1);
56 }
57 }
58  
59 sub does_record_output { 0 }
60 sub wants_input { 0 }
61 sub accept_line {
62 croak "This operation does not accept input.";
63 }
64  
65 1;