Last active
December 20, 2015 01:19
-
-
Save aliles/6048488 to your computer and use it in GitHub Desktop.
Example help output generated by the new subcommands feature for the next release of begins.
https://github.com/aliles/begins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python subcommands.py --help | |
usage: subcommands.py [-h] [-v | -q] | |
[--loglvl {DEBUG,INFO,WARNING,ERROR,CRITICAL}] | |
[--logfile LOGFILE] [--logfmt LOGFMT] | |
{goodbye,hello} ... | |
Greetings and salutations | |
optional arguments: | |
-h, --help show this help message and exit | |
-v, --verbose Increse logging output | |
-q, --quiet Decrease logging output | |
Available subcommands: | |
{goodbye,hello} | |
goodbye Say goodbye | |
hello Say hello | |
logging: | |
Detailed control of logging output | |
--loglvl {DEBUG,INFO,WARNING,ERROR,CRITICAL} | |
Set explicit log level | |
--logfile LOGFILE Ouput log messages to file | |
--logfmt LOGFMT Log message format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python subcommands.py hello --help | |
usage: subcommands.py hello [-h] -n NAME | |
optional arguments: | |
-h, --help show this help message and exit | |
-n NAME, --name NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python subcommands.py hello -n Mick | |
Hello Mick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import begin | |
import logging | |
@begin.subcommand | |
def hello(name): | |
"Say hello" | |
logging.info("Hello {0}".format(name)) | |
@begin.subcommand | |
def goodbye(name): | |
"Say goodbye" | |
logging.info("Goodbye {0}".format(name)) | |
@begin.start | |
@begin.logging | |
def main(): | |
"Greetings and salutations" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment