1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
Metadata-Version: 1.0
Name: opster
Version: 3.7
Summary: command line parsing speedster
Home-page: http://github.com/piranha/opster/
Author: Alexander Solovyov
Author-email: alexander@solovyov.net
License: BSD
Description: .. -*- 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``).
.. note:: Requires at least Python 2.6
Quick example
-------------
That's an example of an option definition::
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] MESSAGE
Simple echo program
options:
-n --no-newline don't print a newline
-h --help show help
As 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
Changelog
---------
3.7 (2012.05.03)
~~~~~~~~~~~~~~~~
- Fixed name in usage on Windows.
- Improved and documented preparsing of global options when using subcommands (GH-25).
3.6 (2012.04.23)
~~~~~~~~~~~~~~~~
- Now commands can have ``-h`` option (GH-2).
- Better Windows compatibility (GH-18, GH-20).
- Refactored internal options representation with easier introspectability
(GH-19).
- Tests support Python 3 (GH-21).
Thanks for this release are going to `Oscar Benjamin`_, every point in this
release is his work.
.. _Oscar Benjamin: https://github.com/oscarbenjamin
3.5 (2012.03.25)
~~~~~~~~~~~~~~~~
- Added `command.Error`_ to facilitate easy exits from scripts (GH-12).
- Fixed opster.t output.
.. _command.Error: http://opster.readthedocs.org/en/latest/overview.html#error-messages
3.4 (2012.01.24)
~~~~~~~~~~~~~~~~
- Fix for installation issue (MANIFEST.in wasn't included).
- Fix for pep8.py complaints (most of them).
- Fix for script name when calling as a command (and not a dispatcher) (GH-4).
- Fix for some 2to3 issues (GH-5).
- Fixed bug with empty arguments for ``opster.command`` (GH-6).
- opster.t is now able to run under ``dash``.
- More output encodings supported (GH-7).
- Coverage support for cram tests (GH-8).
- Fixed combination of varargs and option name with underscore (GH-10).
3.3 (2011.09.04)
~~~~~~~~~~~~~~~~
- Multicommands: ability to specify `global options`_ before specifying name of
command
.. _global options: http://opster.readthedocs.org/en/latest/overview.html#global-options
3.2 (2011.08.27)
~~~~~~~~~~~~~~~~
- `Fix`_ for ``TypeError: func() got multiple values for 'argument'``
.. _Fix: http://opster.readthedocs.org/en/latest/tests.html#multivalues
3.1 (2011.08.27)
~~~~~~~~~~~~~~~~
- Better `aliases`_ support.
- Fixes for options and usage discovery.
- Fix for error handling of dictionary options in multicommands.
- Fix for help not working when global options are defined.
.. _aliases: http://readthedocs.org/docs/opster/en/latest/api.html#opster.command
3.0 (2011.08.14)
~~~~~~~~~~~~~~~~
- **Backward incompatible** Single commands now don't attempt to parse.
arguments if you call them. `Use`_ ``function.command()`` attribute (much like
earlier ``function.help()``) to parse arguments now.
- Switch to Python 2.6.
- Ability to have few subcommand `dispatchers`_ in a single runtime (no single
global ``CMDTABLE`` dictionary anymore).
.. _Use: http://opster.readthedocs.org/en/latest/#quick-example
.. _dispatchers: http://opster.readthedocs.org/en/latest/api.html#opster.Dispatcher
2.2 (2011.03.23)
~~~~~~~~~~~~~~~~
- adjust indentation level in multiline docstrings (compare `1`_ and `2`_)
- small fix for internal getopt exception handling
.. _1: http://opster.readthedocs.org/en/latest/tests.html#multihelp1
.. _2: http://opster.readthedocs.org/en/latest/tests.html#multihelp2
2.1 (2011.01.23)
~~~~~~~~~~~~~~~~
- fix help display in case middleware returns original function
2.0 (2011.01.23)
~~~~~~~~~~~~~~~~
- fix help display when there is no __doc__ declared for function
- ``dict`` type `handling`_
- ``.help()`` attribute for every function, printing help on call
.. _handling: http://opster.readthedocs.org/en/latest/overview.html#options-processing
1.2 (2010.12.29)
~~~~~~~~~~~~~~~~
- fix option display for a list of subcommands if docstring starts with a blank
line
1.1 (2010.12.07)
~~~~~~~~~~~~~~~~
- _completion was failing to work when global options were supplied to command
dispatcher
1.0 (2010.12.06)
~~~~~~~~~~~~~~~~
- when middleware was used and command called without arguments, instead of
help, traceback was displayed
0.9.13 (2010.11.18)
~~~~~~~~~~~~~~~~~~~
- fixed exception handling (cleanup previous fix, actually)
- display only name of application, without full path
0.9.12 (2010.11.02)
~~~~~~~~~~~~~~~~~~~
- fixed trouble with non-ascii characters in docstrings
0.9.11 (2010.09.19)
~~~~~~~~~~~~~~~~~~~
- fixed exceptions handling
- autocompletion improvements (skips middleware, ability of options completion)
0.9.10 (2010.04.10)
~~~~~~~~~~~~~~~~~~~
- if default value of an option is a fuction, always call it (None is passed in
case when option is not supplied)
- always call a function if it's default argument for an option
- some cleanup with better support for python 3
- initial support for autocompletion (borrowed from PIP)
0.9 - 0.9.9 (since 2009.07.13)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ancient history ;-)
Platform: any
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development
|