Parguments is a simple yet elegant command line argument parser , written in and written for Python.
It's easy as
- python::
#coding = utf-8
from parguments import Parguments
pargs = Parguments()
def echo():
"""
display a welcome message.
"""
print("welcome to parguments")
pargs.add_command(echo)
pargs.run()
Create a Parguments instance
python:
from parguments import Parguments as pargs
Add commands
python:
pargs.add_command(function_name, command="", doc="")
Here, function_name is the function in your Python code you want to run when command is called though command line.
doc is a brief "documentation" displayed to user explaining what this command does and needs.
command is optional and will use the function name if not set.
doc is optional and will be OK even if it's empty.
Run the instance
python:
pargs.run(default_command="")
Set the default command and run.
default_command will be run when you simply run your Python code without any arguments.