File Coverage

blib/lib/WWW/MetaForge/ArcRaiders/CLI/Cmd/Traders.pm
Criterion Covered Total %
statement 23 28 82.1
branch 3 6 50.0
condition 1 2 50.0
subroutine 5 5 100.0
pod 0 1 0.0
total 32 42 76.1


line stmt bran cond sub pod time code
1             package WWW::MetaForge::ArcRaiders::CLI::Cmd::Traders;
2             our $AUTHORITY = 'cpan:GETTY';
3             # ABSTRACT: List traders from the ARC Raiders API
4             our $VERSION = '0.002';
5 1     1   7054 use Moo;
  1         3  
  1         11  
6 1     1   582 use MooX::Cmd;
  1         3  
  1         143  
7 1     1   3984 use MooX::Options;
  1         2  
  1         11  
8 1     1   2917 use JSON::MaybeXS;
  1         2  
  1         494  
9              
10             sub execute {
11 1     1 0 4164 my ($self, $args, $chain) = @_;
12 1         3 my $app = $chain->[0];
13              
14 1         41 my $traders = $app->api->traders;
15              
16 1 50       11 if ($app->json) {
17             print JSON::MaybeXS->new(utf8 => 1, pretty => 1)->encode(
18 0         0 [ map { $_->_raw } @$traders ]
  0         0  
19             );
20 0         0 return;
21             }
22              
23 1 50       5 if (!@$traders) {
24 0         0 print "No traders found.\n";
25 0         0 return;
26             }
27              
28 1         4 for my $trader (@$traders) {
29 2   50     46 my $name = $trader->name // 'Unknown';
30 2 50       10 my $inv_count = $trader->inventory ? scalar(@{$trader->inventory}) : 0;
  2         7  
31 2         130 printf "%-30s (%d items)\n", $name, $inv_count;
32             }
33              
34 1         57 printf "\n%d trader(s) found.\n", scalar(@$traders);
35             }
36              
37             1;
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             WWW::MetaForge::ArcRaiders::CLI::Cmd::Traders - List traders from the ARC Raiders API
48              
49             =head1 VERSION
50              
51             version 0.002
52              
53             =head1 SYNOPSIS
54              
55             arcraiders traders
56             arcraiders traders --json
57              
58             =head1 DESCRIPTION
59              
60             List all traders from the ARC Raiders API. Displays trader names and their
61             inventory counts in a simple table format.
62              
63             Use the C<--json> flag (inherited from parent command) to output raw API data
64             as JSON instead of formatted text.
65              
66             =head1 SUPPORT
67              
68             =head2 Issues
69              
70             Please report bugs and feature requests on GitHub at
71             L<https://github.com/Getty/p5-www-metaforge/issues>.
72              
73             =head2 IRC
74              
75             You can reach Getty on C<irc.perl.org> for questions and support.
76              
77             =head1 CONTRIBUTING
78              
79             Contributions are welcome! Please fork the repository and submit a pull request.
80              
81             =head1 AUTHOR
82              
83             Torsten Raudssus <torsten@raudssus.de>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is copyright (c) 2026 by Torsten Raudssus.
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =cut