| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::ARDB::CLI::Cmd::Items; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GETTY'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: List items command |
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
2864
|
use Moo; |
|
|
2
|
|
|
|
|
33
|
|
|
|
2
|
|
|
|
|
15
|
|
|
7
|
2
|
|
|
2
|
|
798
|
use MooX::Cmd; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
40
|
|
|
8
|
2
|
|
|
2
|
|
7881
|
use MooX::Options; |
|
|
2
|
|
|
|
|
7812
|
|
|
|
2
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
option search => ( |
|
14
|
|
|
|
|
|
|
is => 'ro', |
|
15
|
|
|
|
|
|
|
short => 's', |
|
16
|
|
|
|
|
|
|
format => 's', |
|
17
|
|
|
|
|
|
|
doc => 'Search items by name', |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
option type => ( |
|
22
|
|
|
|
|
|
|
is => 'ro', |
|
23
|
|
|
|
|
|
|
short => 't', |
|
24
|
|
|
|
|
|
|
format => 's', |
|
25
|
|
|
|
|
|
|
doc => 'Filter by type', |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
option rarity => ( |
|
30
|
|
|
|
|
|
|
is => 'ro', |
|
31
|
|
|
|
|
|
|
short => 'r', |
|
32
|
|
|
|
|
|
|
format => 's', |
|
33
|
|
|
|
|
|
|
doc => 'Filter by rarity', |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub execute { |
|
38
|
0
|
|
|
0
|
0
|
|
my ($self, $args, $chain) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $app = $chain->[0]; |
|
41
|
0
|
|
|
|
|
|
my $items = $app->api->items; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Apply filters |
|
44
|
0
|
0
|
|
|
|
|
if ($self->search) { |
|
45
|
0
|
|
|
|
|
|
my $search = lc($self->search); |
|
46
|
0
|
|
|
|
|
|
$items = [ grep { index(lc($_->name), $search) >= 0 } @$items ]; |
|
|
0
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if ($self->type) { |
|
50
|
0
|
|
|
|
|
|
my $type = lc($self->type); |
|
51
|
0
|
0
|
|
|
|
|
$items = [ grep { $_->type && lc($_->type) eq $type } @$items ]; |
|
|
0
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if ($self->rarity) { |
|
55
|
0
|
|
|
|
|
|
my $rarity = lc($self->rarity); |
|
56
|
0
|
0
|
|
|
|
|
$items = [ grep { $_->rarity && lc($_->rarity) eq $rarity } @$items ]; |
|
|
0
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if ($app->json) { |
|
60
|
0
|
|
|
|
|
|
$app->output_json([ map { $_->_raw } @$items ]); |
|
|
0
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if (@$items == 0) { |
|
65
|
0
|
|
|
|
|
|
print "No items found.\n"; |
|
66
|
0
|
|
|
|
|
|
return; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
printf "%-30s %-12s %-15s %8s\n", 'Name', 'Rarity', 'Type', 'Value'; |
|
70
|
0
|
|
|
|
|
|
print "-" x 70 . "\n"; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
for my $item (@$items) { |
|
73
|
0
|
|
0
|
|
|
|
printf "%-30s %-12s %-15s %8s\n", |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
74
|
|
|
|
|
|
|
substr($item->name, 0, 30), |
|
75
|
|
|
|
|
|
|
$item->rarity // '-', |
|
76
|
|
|
|
|
|
|
substr($item->type // '-', 0, 15), |
|
77
|
|
|
|
|
|
|
$item->value // '-'; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
print "\n" . scalar(@$items) . " items found.\n"; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |