File Coverage

blib/lib/WWW/MetaForge/ArcRaiders/CLI.pm
Criterion Covered Total %
statement 40 42 95.2
branch 1 2 50.0
condition 1 3 33.3
subroutine 6 7 85.7
pod 0 1 0.0
total 48 55 87.2


line stmt bran cond sub pod time code
1             package WWW::MetaForge::ArcRaiders::CLI;
2             our $AUTHORITY = 'cpan:GETTY';
3             # ABSTRACT: CLI application for MetaForge ARC Raiders API
4             our $VERSION = '0.002';
5              
6 2     2   441052 use Moo;
  2         6859  
  2         13  
7 2     2   2607 use WWW::MetaForge::ArcRaiders;
  2         5  
  2         91  
8 2     2   1637 use Getopt::Long qw(:config pass_through);
  2         23044  
  2         8  
9 2     2   400 use namespace::clean;
  2         4  
  2         31  
10 2     2   3118 use MooX::Cmd;
  2         1113  
  2         56  
11              
12              
13             has debug => (
14             is => 'ro',
15             default => sub { $ENV{WWW_METAFORGE_ARCRAIDERS_DEBUG} // 0 },
16             );
17              
18              
19             has no_cache => (
20             is => 'ro',
21             default => sub { $ENV{WWW_METAFORGE_ARCRAIDERS_NO_CACHE} // 0 },
22             );
23              
24              
25             has json => (
26             is => 'ro',
27             default => sub { $ENV{WWW_METAFORGE_ARCRAIDERS_JSON} // 0 },
28             );
29              
30              
31             around BUILDARGS => sub {
32             my ($orig, $class, @args) = @_;
33              
34             # Parse global options from @ARGV before MooX::Cmd processes it
35             my ($debug, $no_cache, $json);
36             GetOptions(
37             'debug|d' => \$debug,
38             'no-cache' => \$no_cache,
39             'json|j' => \$json,
40             );
41              
42             my $args = $class->$orig(@args);
43             $args->{debug} = $debug if $debug;
44             $args->{no_cache} = $no_cache if $no_cache;
45             $args->{json} = $json if $json;
46              
47             return $args;
48             };
49              
50             has api => (
51             is => 'lazy',
52             builder => '_build_api',
53             );
54              
55              
56             sub _build_api {
57 0     0   0 my ($self) = @_;
58 0         0 return WWW::MetaForge::ArcRaiders->new(
59             debug => $self->debug,
60             use_cache => !$self->no_cache,
61             );
62             }
63              
64             sub execute {
65 1     1 0 1388 my ($self, $args, $chain) = @_;
66              
67             # No subcommand given - show help
68 1 50 33     28 if (!@$chain || @$chain == 1) {
69 1         45 print "metaforge-arcraiders - CLI for MetaForge ARC Raiders API\n\n";
70 1         31 print "Usage: metaforge-arcraiders <command> [options]\n\n";
71 1         16 print "Commands:\n";
72 1         12 print " items List all items (or search)\n";
73 1         14 print " item Show details for a single item\n";
74 1         13 print " quests List all quests\n";
75 1         13 print " quest Show details for a single quest\n";
76 1         13 print " arcs List all ARCs\n";
77 1         12 print " arc Show details for a single arc\n";
78 1         13 print " events Show event timers\n";
79 1         12 print " event Show details for a single event\n";
80 1         27 print " traders List all traders\n";
81 1         17 print "\nOptions:\n";
82 1         13 print " -d, --debug Enable debug output\n";
83 1         13 print " -j, --json Output as JSON\n";
84 1         12 print " --no-cache Disable caching\n";
85 1         12 print "\nExamples:\n";
86 1         12 print " metaforge-arcraiders items --search Ferro\n";
87 1         13 print " metaforge-arcraiders item ferro-i\n";
88 1         12 print " metaforge-arcraiders items --page 3\n";
89 1         13 print " metaforge-arcraiders quests --all\n";
90 1         12 print " metaforge-arcraiders quest a-bad-feeling\n";
91 1         20 print " metaforge-arcraiders events\n";
92             }
93             }
94              
95             1;
96              
97             __END__
98              
99             =pod
100              
101             =encoding UTF-8
102              
103             =head1 NAME
104              
105             WWW::MetaForge::ArcRaiders::CLI - CLI application for MetaForge ARC Raiders API
106              
107             =head1 VERSION
108              
109             version 0.002
110              
111             =head1 SYNOPSIS
112              
113             use WWW::MetaForge::ArcRaiders::CLI;
114             WWW::MetaForge::ArcRaiders::CLI->new_with_cmd;
115              
116             =head1 DESCRIPTION
117              
118             Main CLI class for the ARC Raiders API client. Uses L<MooX::Cmd> for
119             subcommand handling.
120              
121             =head2 debug
122              
123             Enable debug output. Use C<--debug> or C<-d> flag, or set via
124             C<WWW_METAFORGE_ARCRAIDERS_DEBUG> environment variable.
125              
126             =head2 no_cache
127              
128             Disable response caching. Use C<--no-cache> flag, or set via
129             C<WWW_METAFORGE_ARCRAIDERS_NO_CACHE> environment variable.
130              
131             =head2 json
132              
133             Output results as JSON. Use C<--json> or C<-j> flag, or set via
134             C<WWW_METAFORGE_ARCRAIDERS_JSON> environment variable.
135              
136             =head2 api
137              
138             L<WWW::MetaForge::ArcRaiders> instance.
139              
140             =head1 SUPPORT
141              
142             =head2 Issues
143              
144             Please report bugs and feature requests on GitHub at
145             L<https://github.com/Getty/p5-www-metaforge/issues>.
146              
147             =head2 IRC
148              
149             You can reach Getty on C<irc.perl.org> for questions and support.
150              
151             =head1 CONTRIBUTING
152              
153             Contributions are welcome! Please fork the repository and submit a pull request.
154              
155             =head1 AUTHOR
156              
157             Torsten Raudssus <torsten@raudssus.de>
158              
159             =head1 COPYRIGHT AND LICENSE
160              
161             This software is copyright (c) 2026 by Torsten Raudssus.
162              
163             This is free software; you can redistribute it and/or modify it under
164             the same terms as the Perl 5 programming language system itself.
165              
166             =cut