The DuckPAN Tool
DuckPAN is a command line interface to help developers build, test, and configure their Instant Answers. It is available by default in the Codio terminal.
Prints out the DuckPAN man page
If you encounter errors running duckpan, it's often worth first trying to update your environment:
update command will update to the latest version of the duckpan tool:
upgrade command will update both the duckpan tool and the DDG package:
Generating Instant Answer Boilerplate
This will lead you through a dialogue and generate the minimum necessary files with proper naming conventions. This command will only work inside a Goodie or Spice repository, and generate the corresponding Instant Answer.
duckpan new command has several preset file templates you can choose from. To choose a particular preset template:
duckpan new --template TEMPLATE_NAME
The word 'template' in this context refers to file configurations, not frontend HTML templates or template groups. The terminology is admittedly confusing.
In the Goodie repository, your options for
default- creates the basic file types you might need in your Goodie: a Perl file and a test file, both in their correct directories.
cheatsheet- creates the single necessary JSON file for a cheatsheet in the correct directory. For more information see the cheat sheets reference.
In the Spice repository, your options for
You'll also be prompted to add additional template files if you so please. This allows you to selectively add particular boilerplate file types:
Depending on your Instant Answer type, you will also be prompted to choose a handle function handler. This will help generate the right boilerplate for your handle function, and can always be edited later:
1> remainder: (default) The query without the trigger words, spacing and case are preserved. 2> query_raw: Like remainder but with trigger words intact 3> query: Full query normalized with a single space between terms 4> query_lc: Like query but in lowercase 5> query_clean: Like query_lc but with non-alphanumeric characters removed 6> query_nowhitespace: All whitespace removed 7> query_nowhitespace_nodash: All whitespace and hyphens removed 8> matches: Returns an array of captured expression from a regular expression trigger 9> words: Like query_clean but returns an array of the terms split on whitespace 10> query_parts: Like query but returns an array of the terms split on whitespace 11> query_raw_parts: Like query_parts but array contains original whitespace elements Which handler would you like to use to process the query? :
DuckPAN's configurability is rather new, and we look forward to add more templates and configurations in the future. We'd love to hear your thoughts and ideas for how to make this feature more useful to you!
Instant Answer Testing
Test Goodie and Spice triggers interactively on the command line. Typing a query here is just like using DuckDuckGo.com, except you're only viewing the server response, and in its raw form. Learn more about interactive testing.
duckpan server [--verbose] [--no-cache] [--port <number>]
Test Goodie and Spice Instant Answers on a local web server (for design/layout purposes)
--verboseto provide more details
--no-cacheto prevent DuckPAN's cache from being used (this forces the requested files to be pushed into the cache)
--portto specify which port DuckPAN's server should run on (defaults to 5000)
View env commands and also shows the env variables currently stored in ~/.duckpan/env.ini
duckpan env <name> <value>
Add an environment variable that duckpan will remember. Useful for spice API keys. Variables are stored in ~/.duckpan/env.ini
duckpan env <name>
Retrieve the matching key for a given env variable.
duckpan env rm <name>
Remove an environment variable from duckpan
Release the project of the current directory to DuckPAN
Advanced Install Commands
Install all requirements of the specific DuckDuckHack project (if possible), like zeroclickinfo-spice, zeroclickinfo-goodie, duckduckgo or community-platform
installdeps, but avoids testing anything. Useful for speed, but
not recommended unless you know what you are doing.
Check if you fulfill all requirements for the development environment (this is run automatically during setup)
Force installation of the latest released versions of DuckPAN and DDG