summaryrefslogtreecommitdiff
path: root/docs/argument_processing.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/argument_processing.rst')
-rw-r--r--docs/argument_processing.rst39
1 files changed, 0 insertions, 39 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.