| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::MetaForge::ArcRaiders::CLI::Cmd::Items; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GETTY'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: List items from the ARC Raiders API |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
|
5
|
1
|
|
|
1
|
|
9685
|
use Moo; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
1
|
|
|
1
|
|
320
|
use MooX::Cmd; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
7
|
1
|
|
|
1
|
|
3953
|
use MooX::Options; |
|
|
1
|
|
|
|
|
3530
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
1
|
|
|
1
|
|
62417
|
use JSON::MaybeXS; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
516
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
option search => ( |
|
11
|
|
|
|
|
|
|
is => 'ro', |
|
12
|
|
|
|
|
|
|
format => 's', |
|
13
|
|
|
|
|
|
|
short => 's', |
|
14
|
|
|
|
|
|
|
doc => 'Search term to filter items by name', |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
option limit => ( |
|
18
|
|
|
|
|
|
|
is => 'ro', |
|
19
|
|
|
|
|
|
|
format => 'i', |
|
20
|
|
|
|
|
|
|
short => 'l', |
|
21
|
|
|
|
|
|
|
doc => 'Maximum number of results to display', |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
option category => ( |
|
25
|
|
|
|
|
|
|
is => 'ro', |
|
26
|
|
|
|
|
|
|
format => 's', |
|
27
|
|
|
|
|
|
|
short => 'c', |
|
28
|
|
|
|
|
|
|
doc => 'Filter by item category', |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
option rarity => ( |
|
32
|
|
|
|
|
|
|
is => 'ro', |
|
33
|
|
|
|
|
|
|
format => 's', |
|
34
|
|
|
|
|
|
|
short => 'r', |
|
35
|
|
|
|
|
|
|
doc => 'Filter by item rarity', |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
option page => ( |
|
39
|
|
|
|
|
|
|
is => 'ro', |
|
40
|
|
|
|
|
|
|
format => 'i', |
|
41
|
|
|
|
|
|
|
short => 'p', |
|
42
|
|
|
|
|
|
|
doc => 'Page number for pagination', |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
option all => ( |
|
46
|
|
|
|
|
|
|
is => 'ro', |
|
47
|
|
|
|
|
|
|
short => 'a', |
|
48
|
|
|
|
|
|
|
doc => 'Fetch all pages', |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub execute { |
|
52
|
5
|
|
|
5
|
0
|
10707
|
my ($self, $args, $chain) = @_; |
|
53
|
5
|
|
|
|
|
12
|
my $app = $chain->[0]; |
|
54
|
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
8
|
my %params; |
|
56
|
5
|
100
|
|
|
|
23
|
$params{search} = $self->search if $self->search; |
|
57
|
5
|
50
|
|
|
|
17
|
$params{page} = $self->page if $self->page; |
|
58
|
5
|
50
|
|
|
|
15
|
$params{limit} = $self->limit if $self->limit; |
|
59
|
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
11
|
my ($items, $pagination); |
|
61
|
|
|
|
|
|
|
|
|
62
|
5
|
50
|
|
|
|
15
|
if ($self->all) { |
|
63
|
0
|
|
|
|
|
0
|
$items = $app->api->items_all(%params); |
|
64
|
|
|
|
|
|
|
} else { |
|
65
|
5
|
|
|
|
|
140
|
my $result = $app->api->items_paginated(%params); |
|
66
|
5
|
|
|
|
|
1191
|
$items = $result->{data}; |
|
67
|
5
|
|
|
|
|
14
|
$pagination = $result->{pagination}; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Apply local filters |
|
71
|
5
|
100
|
|
|
|
26
|
if ($self->category) { |
|
72
|
1
|
|
|
|
|
4
|
my $cat = lc($self->category); |
|
73
|
1
|
50
|
|
|
|
3
|
$items = [ grep { $_->category && lc($_->category) =~ /\Q$cat\E/ } @$items ]; |
|
|
8
|
|
|
|
|
56
|
|
|
74
|
|
|
|
|
|
|
} |
|
75
|
5
|
100
|
|
|
|
44
|
if ($self->rarity) { |
|
76
|
1
|
|
|
|
|
3
|
my $rar = lc($self->rarity); |
|
77
|
1
|
50
|
|
|
|
14
|
$items = [ grep { $_->rarity && lc($_->rarity) eq $rar } @$items ]; |
|
|
8
|
|
|
|
|
45
|
|
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
5
|
100
|
|
|
|
20
|
if ($app->json) { |
|
81
|
|
|
|
|
|
|
print JSON::MaybeXS->new(utf8 => 1, pretty => 1)->encode( |
|
82
|
1
|
|
|
|
|
9
|
[ map { $_->_raw } @$items ] |
|
|
8
|
|
|
|
|
193
|
|
|
83
|
|
|
|
|
|
|
); |
|
84
|
1
|
|
|
|
|
58
|
return; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
4
|
50
|
|
|
|
12
|
if (!@$items) { |
|
88
|
0
|
|
|
|
|
0
|
print "No items found.\n"; |
|
89
|
0
|
|
|
|
|
0
|
return; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
4
|
|
|
|
|
7
|
for my $item (@$items) { |
|
93
|
20
|
|
33
|
|
|
51
|
my $name = $item->name // $item->id // 'Unknown'; |
|
|
|
|
50
|
|
|
|
|
|
94
|
20
|
|
50
|
|
|
34
|
my $cat = $item->category // '-'; |
|
95
|
20
|
|
50
|
|
|
32
|
my $rar = $item->rarity // '-'; |
|
96
|
20
|
|
33
|
|
|
39
|
my $id = $item->slug // $item->id // '-'; |
|
|
|
|
50
|
|
|
|
|
|
97
|
20
|
|
|
|
|
374
|
printf "%-40s %-18s %-10s [%s]\n", $name, $cat, $rar, $id; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
4
|
|
|
|
|
9
|
my $shown = scalar(@$items); |
|
101
|
4
|
50
|
33
|
|
|
20
|
if ($pagination && !$self->all) { |
|
102
|
4
|
|
50
|
|
|
12
|
my $total = $pagination->{total} // '?'; |
|
103
|
4
|
|
50
|
|
|
10
|
my $page_num = $pagination->{page} // 1; |
|
104
|
4
|
|
50
|
|
|
7
|
my $total_pages = $pagination->{totalPages} // '?'; |
|
105
|
4
|
|
|
|
|
175
|
printf "\n%d item(s) shown (page %d/%s, %s total). Use --all to fetch all pages.\n", |
|
106
|
|
|
|
|
|
|
$shown, $page_num, $total_pages, $total; |
|
107
|
|
|
|
|
|
|
} else { |
|
108
|
0
|
|
|
|
|
|
printf "\n%d item(s) found.\n", $shown; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=pod |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=encoding UTF-8 |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
WWW::MetaForge::ArcRaiders::CLI::Cmd::Items - List items from the ARC Raiders API |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 VERSION |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
version 0.002 |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
arcraiders items |
|
131
|
|
|
|
|
|
|
arcraiders items --search Ferro |
|
132
|
|
|
|
|
|
|
arcraiders items --category Weapon --rarity Rare |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Lists items from the ARC Raiders game database. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 OPTIONS |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item --search, -s |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Search term to filter items by name. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item --limit, -l |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Maximum number of results to display. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item --category, -c |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Filter by item category. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item --rarity, -r |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Filter by item rarity. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item --page, -p |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Page number for pagination. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item --all, -a |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Fetch all pages. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 SUPPORT |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 Issues |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Please report bugs and feature requests on GitHub at |
|
173
|
|
|
|
|
|
|
L<https://github.com/Getty/p5-www-metaforge/issues>. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 IRC |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
You can reach Getty on C<irc.perl.org> for questions and support. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Contributions are welcome! Please fork the repository and submit a pull request. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 AUTHOR |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Torsten Raudssus <torsten@raudssus.de> |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This software is copyright (c) 2026 by Torsten Raudssus. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
192
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |