diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/argument_processing.rst | 39 | ||||
-rw-r--r-- | docs/conf.py | 4 | ||||
-rw-r--r-- | docs/freefeatures.rst | 7 | ||||
-rw-r--r-- | docs/unfreefeatures.rst | 7 |
4 files changed, 5 insertions, 52 deletions
diff --git a/docs/argument_processing.rst b/docs/argument_processing.rst index 08f866b2..183dde4e 100644 --- a/docs/argument_processing.rst +++ b/docs/argument_processing.rst @@ -355,42 +355,3 @@ This example also demonstrates usage of ``cmd_with_subs_completer``. In addition ``cmd_with_subs_completer`` offers more details. .. _subcommands: https://github.com/python-cmd2/cmd2/blob/master/examples/subcommands.py - -Deprecated optparse support -=========================== - -The ``optparse`` library has been deprecated since Python 2.7 (released on July -3rd 2010) and Python 3.2 (released on February 20th, 2011). ``optparse`` is -still included in the python standard library, but the documentation -recommends using ``argparse`` instead. - -``cmd2`` includes a decorator which can parse arguments using ``optparse``. This decorator is deprecated just like the ``optparse`` library. - -Here's an example:: - - from optparse import make_option - from cmd2 import options - - opts = [make_option('-p', '--piglatin', action="store_true", help="atinLay"), - make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"), - make_option('-r', '--repeat', type="int", help="output [n] times")] - - @options(opts, arg_desc='(text to say)') - def do_speak(self, arg, opts=None): - """Repeats what you tell me to.""" - arg = ''.join(arg) - if opts.piglatin: - arg = '%s%say' % (arg[1:], arg[0]) - if opts.shout: - arg = arg.upper() - repetitions = opts.repeat or 1 - for i in range(min(repetitions, self.maxrepeats)): - self.poutput(arg) - - -The optparse decorator performs the following key functions for you: - -1. Use `shlex` to split the arguments entered by the user. -2. Parse the arguments using the given optparse options. -3. Replace the `__doc__` string of the decorated function (i.e. do_speak) with the help string generated by optparse. -4. Call the decorated function (i.e. do_speak) passing an additional parameter which contains the parsed options. diff --git a/docs/conf.py b/docs/conf.py index c654c7bd..97c6269b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,9 +60,9 @@ author = 'Catherine Devlin and Todd Leonhardt' # built documents. # # The short X.Y version. -version = '0.8' +version = '0.9' # The full version, including alpha/beta/rc tags. -release = '0.8.5' +release = '0.9.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index 8255868c..ec43b043 100644 --- a/docs/freefeatures.rst +++ b/docs/freefeatures.rst @@ -213,11 +213,10 @@ of using ``pyscript`` is shown below along with the **examples/arg_printer.py** .. note:: - If you want to be able to pass arguments with spaces to scripts, then we strongly recommend setting the - cmd2 global variable ``USE_ARG_LIST`` to ``True`` in your application using the ``set_use_arg_list`` function. - This passes all arguments to ``@options`` commands as a list of strings instead of a single string. + If you want to be able to pass arguments with spaces to scripts, then we strongly recommend using one of the decorators, + such as ``with_argument_list``. ``cmd2`` will pass your **do_*** methods a list of arguments in this case. - Once this option is set, you can then put arguments in quotes like so:: + When using this decorator, you can then put arguments in quotes like so (NOTE: the ``do_pyscript`` method uses this decorator:: (Cmd) pyscript examples/arg_printer.py hello '23 fnord' Running Python script 'arg_printer.py' which was called with 2 arguments diff --git a/docs/unfreefeatures.rst b/docs/unfreefeatures.rst index 2d6c8c3c..d420797d 100644 --- a/docs/unfreefeatures.rst +++ b/docs/unfreefeatures.rst @@ -137,13 +137,6 @@ There are a couple functions which can globally effect how arguments are parsed .. autofunction:: cmd2.set_strip_quotes -.. warning:::: - - Since optparse_ has been deprecated since Python 3.2, the ``cmd2`` developers have deprecated the old optparse-based - ``@options`` decorator. This decorator still exists in the codebase, but it will be removed in a future release. - We recommend using one of the new argparse-based decorators. - -.. _optparse: https://docs.python.org/3/library/optparse.html .. _argparse: https://docs.python.org/3/library/argparse.html |