Skip to content

Instantly share code, notes, and snippets.

@luztak
Last active December 11, 2015 20:09
Show Gist options
  • Save luztak/4653579 to your computer and use it in GitHub Desktop.
Save luztak/4653579 to your computer and use it in GitHub Desktop.
parguments README.rst

parguments

Parguments is a simple yet elegant command line argument parser , written in and written for Python.

Howto

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.

Happy Coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment