Python Package – begins
Need to convert a Python function into a command line tool? Take a look at begins:
Command line programs for lazy humans.
The following is an example from the documentation:
# holygrail_py3.py
import begin
@begin.start
def run(name: 'What, is your name?',
quest: 'What, is your quest?',
colour: 'What, is your favourite colour?'):
pass
Decorating the run
function as above automatically creates the following command:
usage: holygrail_py3.py [-h] -n NAME -q QUEST -c COLOUR
optional arguments:
-h, --help show this help message and exit
-n NAME, --name NAME What, is your name?
-q QUEST, --quest QUEST
What, is your quest?
-c COLOUR, --colour COLOUR
What, is your favourite colour?
Fire is an alternative package, that is more customisable (allows sub-commands) but it’s help command is more obtuse (command -- -help
).