File Coverage

bin/duckpan
Criterion Covered Total %
statement 35 35 100.0
branch 5 6 83.3
condition n/a
subroutine 8 8 100.0
pod n/a
total 48 49 97.9


line stmt bran cond sub pod time code
1             #!/usr/bin/env perl
2             # PODNAME: duckpan
3             # ABSTRACT: Command line tool for using the DuckPAN of DuckDuckGo
4              
5 4     4   28 use strict; use warnings;
  4     4   8  
  4         108  
  4         18  
  4         9  
  4         145  
6              
7 2         6 my @libs;
8              
9             BEGIN {
10 4     4   2745 use Getopt::Long qw/:config bundling pass_through/;
  4         46765  
  4         25  
11 4     4   4030 use Path::Tiny;
  4         38094  
  4         259  
12 4     4   2232 use Try::Tiny;
  4         7396  
  4         964  
13 4     4   29 GetOptions 'include|I=s' => \@libs;
14 4         1289 @libs = split ',', join ',', @libs;
15 4 100       17 if (my @missing = grep { !$_->exists } map { path($_) } @libs) {
  2         137  
  2         13  
16 2 50       170 my $plural = (scalar @missing == 1) ? '' : 's';
17             print STDERR '[FATAL ERROR] Missing include path' . $plural . ': ' . join(', ',
18 2 100       11 map { try { $_->realpath } || $_->absolute } @missing) . "\n";
  2         13  
  2         86  
19 2         2283 exit 1;
20             }
21              
22             # For other commands, bundling is desirable but pass_through leads to
23             # incomplete validation of command line arguments
24 2         9 Getopt::Long::Configure('no_pass_through');
25             }
26 2     2   1038 use lib @libs;
  2         946  
  2         11  
27              
28 2         10 $|=1;
29              
30 2     2   1020 use App::DuckPAN;
  2         16  
  2         7750  
31 2         27 App::DuckPAN->new_with_cmd;
32              
33             __END__
34              
35             =pod
36              
37             =head1 NAME
38              
39             duckpan - Command line tool for using the DuckPAN of DuckDuckGo
40              
41             =head1 VERSION
42              
43             version 1019
44              
45             =head1 SYNOPSIS
46              
47             duckpan [-I=<path>] [-v|--verbose] <command> [<args>]
48              
49             Commands include:
50              
51             check Check if you fulfill all requirements for the development environment
52             env Add, remove or retrieve values from DuckPAN's Env.ini
53             help View more detailed help information
54             installdeps Install all Perl dependencies
55             new Generate new Instant Answer skeleton
56             publisher Start local web server for DuckDuckGo-Publisher static websites
57             query Test Instant Answer triggers on command line
58             reinstall Reinstalls installed, pinned, or most recent DuckPAN and DDG Perl modules
59             latest Like reintall but ignores installed versions
60             roadrunner Same as installdeps, but skips tests (dangerous!)
61             server Start local web server to test Instant Answer display
62             update Installs newest DuckPAN packages
63             upgrade Installs newest DuckPAN and DDG packages
64              
65             Use 'duckpan help' or 'man duckpan' for more details.
66              
67             =head1 DESCRIPTION
68              
69             DuckPAN is an application built to aid DuckDuckHack contributors with Instant Answer development. It is mainly used by contributors to test Instant Answer triggers and preview their visual design and output.
70              
71             =head1 NAME
72              
73             DuckPAN - The DuckDuckHack Developer Tool
74              
75             =head1 INSTALLATION
76              
77             Please see L<https://github.com/duckduckgo/p5-app-duckpan#installing-duckpan> for DuckPAN installation instructions
78              
79             =head1 COMMANDS
80              
81             =head2 Help
82              
83             =over 4
84              
85             =item C<duckpan> OR C<duckpan help> OR C<man duckpan>
86              
87             Shows you the DuckPAN help page which briefly describes DuckPAN and its features.
88              
89             =back
90              
91             =head2 FOR INSTANT ANSWER DEVELOPERS
92              
93             =over 4
94              
95             =item C<duckpan check>
96              
97             Checks if you fulfill all requirements for the development environment. This will run automatically during a B<duckpan release>.
98              
99             =item C<duckpan query> [package_name ...]
100              
101             Test Goodie and Spice triggers interactively on the command line. For each query, the Instant Answers triggered will be displayed. This tool should be used to ensure your Instant Answer triggers correctly.
102              
103             [package_name ...]:
104             Loads only the specified Spice or Goodie Instant Answers.
105              
106             Examples:
107             duckpan query Npm
108             duckpan query Twitter IsItUp
109              
110             =item C<duckpan server> [--port <number>] [package_name ...]
111              
112             Starts a local web server, which emulates the DuckDuckGo production environment. Allows for live testing of Goodie and Spice Instant Answers. This tool should be used to ensure your Instant Answer displays correctly. For Spice Instant Answers, this is especially important to verify API calls are successful and no JavaScript errors exist.
113              
114             -p, --port <number>:
115             Forces DuckPAN server to run on the specified port (default port is 5000)
116              
117             [package_name ...]:
118             Loads only the specified Spice or Goodie Instant Answers.
119              
120             Examples:
121             duckpan server Movie
122             duckpan server IDN Sort Morse
123              
124             =item C<duckpan new> [package name]
125              
126             Generates all necessary files for a new Spice or Goodie Instant Answer (depending on the current repo). DuckPAN will prompt you for a package name and generate the required files. If the name is already in use, DuckPAN will let you know and no files will be created.
127              
128             =item C<duckpan test>
129              
130             Tests your release, by running the tests in the B<t/> directory using Dzil (if a dist.ini exists) or prove. This will run automatically during a B<duckpan release>.
131              
132             =item C<duckpan installdeps>
133              
134             Attempt to install dependencies for the distribution in your current directory using cpanm.
135              
136             =item C<duckpan roadrunner>
137              
138             Same as installdeps, but without testing them. Meep meep!
139              
140             =item C<duckpan publisher>
141              
142             Starts a local web server which displays static websites created with L<DuckDuckGo-Publisher|https://github.com/duckduckgo/duckduckgo-publisher>.
143              
144             =item C<duckpan update>
145              
146             Update DuckPAN to the latest version.
147              
148             =item C<duckpan upgrade>
149              
150             Upgrade DuckPAN and DDG to the latest versions.
151              
152             =back
153              
154             =head2 FOR DUCKPAN DEVELOPERS
155              
156             =over 4
157              
158             =item C<duckpan reinstall>
159              
160             Force installation of DuckPAN and DDG modules using the installed, pinned, or latest versions, in that order.
161              
162             =item C<duckpan latest>
163              
164             Like L<reinstall> except it ignores any installed version.
165              
166             =item C<duckpan -I [filepath ...]>
167              
168             Loads the specified external library. This should be used to test changes made to L<App::DuckPAN> and L<DDG>. Example: loading modified DuckPAN modules C<duckpan -I../p5-app-duckpan/lib server>.
169              
170             =back
171              
172             =head1 ENVIRONMENT VARIABLES
173              
174             =over 4
175              
176             =item C<duckpan env>
177              
178             View env commands and shows command usage.
179              
180             =item C<duckpan env help>
181              
182             View env commands and shows command usage.
183              
184             =item C<duckpan env set> <name> <value>
185              
186             Add an environment variable that DuckPAN will remember. This is specifically useful for Spice API keys. Variables are stored in ~/.duckpan/config/env.ini
187              
188             =item C<duckpan env get> <name>
189              
190             Retrieve the matching key for a given env variable.
191              
192             =item C<duckpan env rm> <name>
193              
194             Remove an environment variable from DuckPAN.
195              
196             =item C<duckpan env list>
197              
198             Lists all the env variables currently stored in ~/.duckpan/config/env.ini.
199              
200             =back
201              
202             =head1 SEE ALSO
203              
204             =over 4
205              
206             =item L<https://github.com/duckduckgo/p5-app-duckpan>
207              
208             =item L<https://github.com/duckduckgo>
209              
210             =item L<https://duckduckgo.com>
211              
212             =item L<https://duck.co>
213              
214             =item L<http://duckpan.org>
215              
216             =back
217              
218             =head1 CONTRIBUTION
219              
220             To contribute to DuckPAN, please visit L<https://github.com/duckduckgo/p5-app-duckpan>. We also welcome and encourage contributions from our community. Please visit L<http://duckduckhack.com/> to contribute new Instant Answers, or visit L<https://duck.co/ideas> to share your ideas and Instant Answer source suggestions.
221              
222             =head1 SUPPORT
223              
224             =over 4
225              
226             =item B<Slack>
227              
228             We invite you to join us on L<Slack|https://quackslack.herokuapp.com/> for any queries and lively discussion.
229              
230             =item B<Repository>
231              
232             L<https://github.com/duckduckgo/p5-app-duckpan>
233              
234             =item B<Issue Tracker>
235              
236             L<https://github.com/duckduckgo/p5-app-duckpan/issues>
237              
238             =back
239              
240             =head1 AUTHOR
241              
242             DuckDuckGo <open@duckduckgo.com>, Zach Thompson <zach@duckduckgo.com>, Zaahir Moolla <moollaza@duckduckgo.com>, Torsten Raudssus <torsten@raudss.us> L<https://raudss.us/>
243              
244             =head1 COPYRIGHT AND LICENSE
245              
246             This software is Copyright (c) 2013 by DuckDuckGo, Inc. L<https://duckduckgo.com/>.
247              
248             This is free software, licensed under:
249              
250             The Apache License, Version 2.0, January 2004
251              
252             =cut