Created
July 20, 2011 05:05
-
-
Save amcgregor/1094377 to your computer and use it in GitHub Desktop.
Example marrow.script help generation output.
This file contains hidden or 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
class Service(object): | |
"""Example service. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | |
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim | |
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea | |
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate | |
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat | |
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id | |
est laborum. | |
""" | |
def __init__(self, verbose=False, quiet=False): | |
if verbose and quiet: | |
print("Can not set verbose and quiet simultaneously.") | |
return 1 | |
logging.basicConfig(level=logging.DEBUG if verbose else logging.WARN if quiet else logging.INFO) | |
self.log = logging.getLogger(__name__) | |
self.log.info("Initialized.") | |
def start(self, config=None, app=None): | |
"""Pretend to start the service. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do | |
eiusmod tempor incididunt ut labore et dolore magna aliqua. | |
""" | |
self.log.info("Starting %s from %s configuration%s.", | |
app if app else "default application", | |
config if config else 'default', | |
' file' if config else '') | |
def stop(self, config=None): | |
self.log.info("Stopping service.") | |
def restart(self, config=None, app=None): | |
self.stop(config) | |
self.start(config, app) | |
def reload(self, config=None): | |
self.log.info("Reloading configuration.") |
This file contains hidden or 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 service.py -h | |
Example service. | |
Usage: service.py [OPTIONS] <COMMAND> ... | |
OPTIONS may be one or more of: | |
-h, --help Display this help and exit. | |
-q, --quiet Toggle this value. | |
Default: False | |
-v, --verbose Toggle this value. | |
Default: False | |
COMMAND may be one of: | |
reload Undocumented command. | |
restart Undocumented command. | |
start Pretend to start the service. | |
stop Undocumented command. | |
For help on a specific command, call the command and pass --help in CMDOPTS. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | |
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis | |
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | |
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu | |
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in | |
culpa qui officia deserunt mollit anim id est laborum. |
This file contains hidden or 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 service.py start -h | |
Example service. | |
Usage: service.py [OPTIONS] start [CMDOPTS] | |
OPTIONS may be one or more of: | |
-h, --help Display this help and exit. | |
-q, --quiet Toggle this value. | |
Default: False | |
-v, --verbose Toggle this value. | |
Default: False | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | |
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis | |
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | |
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu | |
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in | |
culpa qui officia deserunt mollit anim id est laborum. | |
Command: start | |
Pretend to start the service. | |
CMDOPTS may be one or more of: | |
-a, --app=VAL Override this value. | |
Default: None | |
-c, --config=VAL Override this value. | |
Default: None | |
-h, --help Display this help and exit. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | |
incididunt ut labore et dolore magna aliqua. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment