diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/freefeatures.rst | 8 | ||||
-rw-r--r-- | docs/requirements.txt | 3 | ||||
-rw-r--r-- | docs/settingchanges.rst | 2 | ||||
-rw-r--r-- | docs/unfreefeatures.rst | 60 |
4 files changed, 15 insertions, 58 deletions
diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index 419dc7d8..156b003e 100644 --- a/docs/freefeatures.rst +++ b/docs/freefeatures.rst @@ -32,11 +32,7 @@ Comments Comments are omitted from the argument list before it is passed to a ``do_`` method. By default, both Python-style and C-style comments -are recognized; you may change this by overriding -``app.commentGrammars`` with a different pyparsing_ -grammar (see the arg_print_ example for specifically how to to this). - -Comments can be useful in :ref:`scripts`, but would +are recognized. Comments can be useful in :ref:`scripts`, but would be pointless within an interactive session. :: @@ -49,7 +45,6 @@ be pointless within an interactive session. (Cmd) speak it was /* not */ delicious! # Yuck! it was delicious! -.. _pyparsing: http://pyparsing.wikispaces.com/ .. _arg_print: https://github.com/python-cmd2/cmd2/blob/master/examples/arg_print.py Startup Initialization Script @@ -102,6 +97,7 @@ Output redirection As in a Unix shell, output of a command can be redirected: - sent to a file with ``>``, as in ``mycommand args > filename.txt`` + - appended to a file with ``>>``, as in ``mycommand args >> filename.txt`` - piped (``|``) as input to operating-system commands, as in ``mycommand args | wc`` - sent to the paste buffer, ready for the next Copy operation, by diff --git a/docs/requirements.txt b/docs/requirements.txt index d22f9341..011603fb 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,3 @@ -pyparsing +colorama pyperclip wcwidth -colorama diff --git a/docs/settingchanges.rst b/docs/settingchanges.rst index 8e87d341..02955273 100644 --- a/docs/settingchanges.rst +++ b/docs/settingchanges.rst @@ -44,7 +44,7 @@ To define more shortcuts, update the dict ``App.shortcuts`` with the Shortcuts need to be created by updating the ``shortcuts`` dictionary attribute prior to calling the ``cmd2.Cmd`` super class ``__init__()`` method. Moreover, that super class init method needs to be called after updating the ``shortcuts`` attribute This warning applies in general to many other attributes which are not - settable at runtime such as ``commentGrammars``, ``multilineCommands``, etc. + settable at runtime such as ``multiline_commands``, etc. Aliases diff --git a/docs/unfreefeatures.rst b/docs/unfreefeatures.rst index d420797d..6f22c1e0 100644 --- a/docs/unfreefeatures.rst +++ b/docs/unfreefeatures.rst @@ -7,7 +7,7 @@ Multiline commands Command input may span multiple lines for the commands whose names are listed in the -parameter ``app.multilineCommands``. These +parameter ``app.multiline_commands``. These commands will be executed only after the user has entered a *terminator*. By default, the command terminators is @@ -22,11 +22,9 @@ Parsed statements ================= ``cmd2`` passes ``arg`` to a ``do_`` method (or -``default``) as a ParsedString, a subclass of -string that includes an attribute ``parsed``. -``parsed`` is a ``pyparsing.ParseResults`` -object produced by applying a pyparsing_ -grammar applied to ``arg``. It may include: +``default``) as a Statement, a subclass of +string that includes many attributes of the parsed +input: command Name of the command called @@ -37,47 +35,21 @@ raw terminator Character used to end a multiline command -suffix - Remnant of input after terminator +command_and_args + A string of just the command and the arguments, with + output redirection or piping to shell commands removed -:: - - def do_parsereport(self, arg): - self.stdout.write(arg.parsed.dump() + '\n') +If ``Statement`` does not contain an attribute, +querying for it will return ``None``. -:: - - (Cmd) parsereport A B /* C */ D; E - ['parsereport', 'A B D', ';', 'E'] - - args: A B D - - command: parsereport - - raw: parsereport A B /* C */ D; E - - statement: ['parsereport', 'A B D', ';'] - - args: A B D - - command: parsereport - - terminator: ; - - suffix: E - - terminator: ; - -If ``parsed`` does not contain an attribute, -querying for it will return ``None``. (This -is a characteristic of ``pyparsing.ParseResults``.) - -The parsing grammar and process currently employed -by cmd2 is stable, but is likely significantly more -complex than it needs to be. Future ``cmd2`` releases may -change it somewhat (hopefully reducing complexity). - -(Getting ``arg`` as a ``ParsedString`` is +(Getting ``arg`` as a ``Statement`` is technically "free", in that it requires no application changes from the cmd_ standard, but there will be no result unless you change your application -to *use* ``arg.parsed``.) +to *use* any of the additional attributes.) .. _cmd: https://docs.python.org/3/library/cmd.html -.. _pyparsing: http://pyparsing.wikispaces.com/ - Environment parameters ====================== @@ -129,16 +101,6 @@ that module. ``cmd2`` defines a few decorators which change the behavior of how arguments get parsed for and passed to a ``do_`` method. See the section :ref:`decorators` for more information. -Controlling how arguments are parsed for commands with flags ------------------------------------------------------------- -There are a couple functions which can globally effect how arguments are parsed for commands with flags: - -.. autofunction:: cmd2.set_posix_shlex - -.. autofunction:: cmd2.set_strip_quotes - -.. _argparse: https://docs.python.org/3/library/argparse.html - poutput, pfeedback, perror, ppaged ================================== |