line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Haineko::CLI::Help; |
2
|
1
|
|
|
1
|
|
4498
|
use parent 'Haineko::CLI'; |
|
1
|
|
|
|
|
647
|
|
|
1
|
|
|
|
|
5
|
|
3
|
1
|
|
|
1
|
|
45
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
583
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
1
|
|
|
1
|
1
|
24
|
my $class = shift; |
8
|
1
|
|
|
|
|
6
|
my $argvs = { @_ }; |
9
|
1
|
|
|
|
|
13
|
my $thing = __PACKAGE__->SUPER::new( %$argvs ); |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
12
|
$thing->{'params'} = { |
12
|
|
|
|
|
|
|
'option' => [], |
13
|
|
|
|
|
|
|
'example' => [], |
14
|
|
|
|
|
|
|
'subcommand' => [], |
15
|
|
|
|
|
|
|
}; |
16
|
1
|
|
|
|
|
4
|
return $thing; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub add { |
20
|
10
|
|
|
10
|
1
|
6032
|
my $self = shift; |
21
|
10
|
|
|
|
|
14
|
my $argv = shift; |
22
|
10
|
|
|
|
|
12
|
my $type = shift; |
23
|
10
|
|
|
|
|
14
|
my $data = $self->{'params'}; |
24
|
|
|
|
|
|
|
|
25
|
10
|
100
|
|
|
|
24
|
return $data unless defined $argv; |
26
|
9
|
100
|
|
|
|
21
|
return $data unless ref $argv; |
27
|
8
|
100
|
|
|
|
19
|
return $data unless ref $argv eq 'ARRAY'; |
28
|
|
|
|
|
|
|
|
29
|
7
|
100
|
100
|
|
|
64
|
if( $type eq 'o' || $type eq 'option' ) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
30
|
|
|
|
|
|
|
# Option |
31
|
2
|
|
|
|
|
48
|
$data = $self->{'params'}->{'option'}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} elsif( $type eq 'e' || $type eq 'example' ) { |
34
|
|
|
|
|
|
|
# Example |
35
|
2
|
|
|
|
|
6
|
$data = $self->{'params'}->{'example'}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} elsif( $type eq 's' || $type eq 'subcommand' ) { |
38
|
|
|
|
|
|
|
# Subcommand |
39
|
2
|
|
|
|
|
4
|
$data = $self->{'params'}->{'subcommand'}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} else { |
42
|
1
|
|
|
|
|
5
|
return $data; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
6
|
|
|
|
|
9
|
push @$data, @$argv; |
46
|
6
|
|
|
|
|
12
|
return $data; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub mesg { |
50
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $messageset = []; |
53
|
0
|
|
|
|
|
|
my $offsetsize = []; |
54
|
0
|
|
|
|
|
|
my $indentsize = 2; |
55
|
0
|
|
|
|
|
|
my $maxlength1 = 0; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
for my $e ( 'subcommand', 'option' ) { |
58
|
0
|
|
|
|
|
|
my @f = @{ $self->{'params'}->{ $e } }; |
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $l = 0; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
while( my $r = shift @f ) { |
62
|
0
|
0
|
|
|
|
|
next unless scalar @f % 2; |
63
|
0
|
|
|
|
|
|
$l = length $r; |
64
|
0
|
0
|
|
|
|
|
$maxlength1 = $l > $maxlength1 ? $l : $maxlength1; |
65
|
0
|
|
|
|
|
|
push @$offsetsize, $l; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
printf( STDERR "%s SUBCOMMAND [OPTION]\n", $self->command ); |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
for my $e ( 'subcommand', 'option' ) { |
72
|
0
|
|
|
|
|
|
my @f = @{ $self->{'params'}->{ $e } }; |
|
0
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $v = q(); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
while( my $r = shift @f ) { |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
if( scalar @f % 2 ) { |
78
|
0
|
|
|
|
|
|
$v = $r; |
79
|
0
|
|
|
|
|
|
next; |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
$v .= '%s : '.$r; |
82
|
0
|
|
|
|
|
|
push @$messageset, $v; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
next unless scalar @$messageset; |
86
|
0
|
0
|
|
|
|
|
printf( STDERR " %s:\n", uc $e ) if scalar @$messageset; |
87
|
0
|
|
|
|
|
|
while( my $r = shift @$messageset ) { |
88
|
0
|
|
|
|
|
|
my $o = shift @$offsetsize; |
89
|
0
|
|
|
|
|
|
printf( STDERR " %s", ' ' x $indentsize ); |
90
|
0
|
|
|
|
|
|
printf( STDERR $r, ' ' x ( $maxlength1 - $o + 2 ) ); |
91
|
0
|
|
|
|
|
|
printf( STDERR "\n" ); |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
printf( STDERR "\n" ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
if( scalar @{ $self->{'params'}->{'example'} } ) { |
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
printf( STDERR " FOR EXAMPLE:\n" ); |
98
|
0
|
|
|
|
|
|
for my $e ( @{ $self->{'params'}->{'example'} } ) { |
|
0
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
printf( STDERR " %s\n", $e ); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
__END__ |