line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ================================================================ |
2
|
|
|
|
|
|
|
package App::iTan::Command::List; |
3
|
|
|
|
|
|
|
# ================================================================ |
4
|
1
|
|
|
1
|
|
1197
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
5
|
1
|
|
|
1
|
|
589
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use 5.0100; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = $App::iTan::VERSION; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use MooseX::App::Command; |
11
|
|
|
|
|
|
|
with qw(App::iTan::Utils); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Text::Table; |
14
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints qw(enum); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @SORTFIELDS = qw(tindex imported used); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
option 'sort' => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => enum(\@SORTFIELDS), |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
default => $SORTFIELDS[0], |
23
|
|
|
|
|
|
|
documentation => q[Set list sorting (].(join ',',@SORTFIELDS).q[)], |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub execute { |
27
|
|
|
|
|
|
|
my ( $self, $opts, $args ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $tb = $self->get_table(); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
print $tb->title; |
32
|
|
|
|
|
|
|
print $tb->rule('-','+'); |
33
|
|
|
|
|
|
|
print $tb->body; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_table { |
39
|
|
|
|
|
|
|
my ($self) = @_; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $sort = $self->sort; |
42
|
|
|
|
|
|
|
$sort .= ','.$SORTFIELDS[0] |
43
|
|
|
|
|
|
|
unless $SORTFIELDS[0] eq $sort; |
44
|
|
|
|
|
|
|
my $sth = $self->dbh->prepare("SELECT tindex,imported,used,memo |
45
|
|
|
|
|
|
|
FROM itan |
46
|
|
|
|
|
|
|
WHERE valid = 1 OR used IS NOT NULL |
47
|
|
|
|
|
|
|
ORDER BY $sort") |
48
|
|
|
|
|
|
|
or die "ERROR: Cannot prepare: " . $self->dbh->errstr(); |
49
|
|
|
|
|
|
|
$sth->execute(); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $tb = Text::Table->new( |
52
|
|
|
|
|
|
|
"Index",\"|","Imported",\"|","Used",\"|","Memo" |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
while (my @line = $sth->fetchrow_array) { |
56
|
|
|
|
|
|
|
$tb->add(@line); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $tb; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding utf8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
App::iTan::Command::List - List of all iTANs |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SYNOPSIS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
itan list [--sort (tindex imported used)] |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
List of all either used or still available iTANs. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 OPTIONS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 sort |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Set list sorting. Available options are |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=over |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * tindex |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * imported |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * used |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |