Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piranha/opster
Command line parsing speedster
https://github.com/piranha/opster
command-line-parser python
Last synced: 10 days ago
JSON representation
Command line parsing speedster
- Host: GitHub
- URL: https://github.com/piranha/opster
- Owner: piranha
- Created: 2011-08-16T08:37:41.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T10:52:47.000Z (almost 2 years ago)
- Last Synced: 2024-10-23T03:28:03.039Z (18 days ago)
- Topics: command-line-parser, python
- Language: Python
- Homepage: http://opster.rtfd.org/
- Size: 303 KB
- Stars: 51
- Watchers: 3
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
.. -*- mode: rst -*-
========
Opster
========Opster is a command line options parser, intended to make writing command line
applications easy and painless. It uses built-in Python types (lists,
dictionaries, etc) to define options, which makes configuration clear and
concise. Additionally it contains possibility to handle subcommands (i.e.
``hg commit`` or ``svn update``)... image:: https://github.com/piranha/opster/actions/workflows/build.yml/badge.svg
:target: https://github.com/piranha/opster/actions**Supported Python versions**: Python >= 3.2
Quick example
-------------That's an example of an option definition
.. code:: python
import sys
from opster import command@command()
def main(message,
no_newline=('n', False, "don't print a newline")):
'''Simple echo program'''
sys.stdout.write(message)
if not no_newline:
sys.stdout.write('\n')if __name__ == '__main__':
main.command()Running this program will print help message::
> ./echo.py
echo.py: invalid arguments
echo.py [OPTIONS] MESSAGESimple echo program
options:
-n --no-newline don't print a newline
-h --help show helpAs you can see, here we have defined option to not print newline: keyword
argument name is a long name for option, default value is a 3-tuple, containing
short name for an option (can be empty), default value (on base of which
processing is applied - `see description`_) and a help string.Underscores in long names of options are converted into dashes.
If you are calling a command with option using long name, you can supply it
partially. In this case it could look like ``./echo.py --no-new``. This is also
true for subcommands: read about them and everything else you'd like to know in
`documentation`_... _documentation: http://opster.readthedocs.org/en/latest/
.. _see description: http://opster.readthedocs.org/en/latest/overview.html#options-processing