Skip to content

Instantly share code, notes, and snippets.

@kevinballard
Created May 22, 2013 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinballard/5631361 to your computer and use it in GitHub Desktop.
Save kevinballard/5631361 to your computer and use it in GitHub Desktop.
Example interaction with commandr.
$ python example.py
> Command must be specified
>
> General Commands:
> greet
$ python example.py greet
> All options without default values must be specified
>
> Current Options:
> --name=None
> --title=Mr.
> --times=1
>
> Documentation for command 'greet':
> ----------------------------------------
> Greet someone.
> Arguments:
> name - Name to greet.
> title - Title of the person to greet.
> times - Number of times to say the greeting.
> ----------------------------------------
>
> Usage: example.py command [options]
> Options without default values MUST be specified
>
> Options:
> -h, --help
> -n NAME, --name=NAME
> -t TITLE, --title=TITLE
> [default: "Mr."]
> --times=TIMES [default: 1]
$ python example.py greet --name Smith
> Hi Mr. Smith!
$ python example.py greet John --times blah
> Usage: example.py command [options]
> Options without default values MUST be specified
>
> example.py: error: option --times: invalid integer value: 'blah'
$ python example.py greet Nick Dr. --times 2
> Hi Dr. Nick!
> Hi Dr. Nick!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment