Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hyde/commando
argparse in style
https://github.com/hyde/commando
Last synced: 3 days ago
JSON representation
argparse in style
- Host: GitHub
- URL: https://github.com/hyde/commando
- Owner: hyde
- License: mit
- Created: 2010-12-16T18:19:42.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2020-12-23T07:14:42.000Z (almost 4 years ago)
- Last Synced: 2024-09-18T11:46:35.153Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 270 KB
- Stars: 39
- Watchers: 7
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
============================
commando - argparse in style
============================**Version 1.0.0**
A simple wrapper for ``argparse`` that allows commands and arguments
to be defined declaratively using decorators. Note that this does
not support all the features of ``argparse`` yet.Commando also bundles a few utilities that are useful when building
command line applications.Example
--------Without commando::
def main():
parser = argparse.ArgumentParser(description='hyde - a python static website generator',
epilog='Use %(prog)s {command} -h to get help on individual commands')
parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__)
parser.add_argument('-s', '--sitepath', action='store', default='.', help="Location of the hyde site")
subcommands = parser.add_subparsers(title="Hyde commands",
description="Entry points for hyde")
init_command = subcommands.add_parser('init', help='Create a new hyde site')
init_command.set_defaults(run=init)
init_command.add_argument('-t', '--template', action='store', default='basic', dest='template',
help='Overwrite the current site if it exists')
init_command.add_argument('-f', '--force', action='store_true', default=False, dest='force',
help='Overwrite the current site if it exists')
args = parser.parse_args()
args.run(args)def init(self, params):
print params.sitepath
print params.template
print params.overwriteWith commando::
class Engine(Application):
@command(description='hyde - a python static website generator',
epilog='Use %(prog)s {command} -h to get help on individual commands')
@param('-v', '--version', action='version', version='%(prog)s ' + __version__)
@param('-s', '--sitepath', action='store', default='.', help="Location of the hyde site")
def main(self, params): pass@subcommand('init', help='Create a new hyde site')
@param('-t', '--template', action='store', default='basic', dest='template',
help='Overwrite the current site if it exists')
@param('-f', '--force', action='store_true', default=False, dest='overwrite',
help='Overwrite the current site if it exists')
def init(self, params):
print params.sitepath
print params.template
print params.overwriteResources
---------1. `Changelog`_
2. `License`_
3. `Contributing`_
4. `Authors`_.. _Changelog: CHANGELOG.rst
.. _LICENSE: LICENSE
.. _Contributing: CONTRIBUTING.rst
.. _Authors: AUTHORS.rst