diff options
author | kotfu <kotfu@kotfu.net> | 2018-04-29 16:12:31 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-04-29 16:12:31 -0600 |
commit | 1097de13a26cab91a3e35bcdba801c19de07b06b (patch) | |
tree | 56cad460e8a3e6b5430495279a84313bbded0957 | |
parent | 1297be25d68b0c8e511b819c906f0d5e0a942606 (diff) | |
download | cmd2-git-1097de13a26cab91a3e35bcdba801c19de07b06b.tar.gz |
Clean up documentation references to pyparsing
-rw-r--r-- | docs/freefeatures.rst | 8 | ||||
-rw-r--r-- | docs/unfreefeatures.rst | 48 | ||||
-rwxr-xr-x | examples/arg_print.py | 5 |
3 files changed, 13 insertions, 48 deletions
diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index a7a112fc..b3f038b0 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/unfreefeatures.rst b/docs/unfreefeatures.rst index 16d0eb08..6f22c1e0 100644 --- a/docs/unfreefeatures.rst +++ b/docs/unfreefeatures.rst @@ -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 ====================== diff --git a/examples/arg_print.py b/examples/arg_print.py index bd8ff6be..95e8ff01 100755 --- a/examples/arg_print.py +++ b/examples/arg_print.py @@ -21,13 +21,10 @@ class ArgumentAndOptionPrinter(cmd2.Cmd): """ Example cmd2 application where we create commands that just print the arguments they are called with.""" def __init__(self): - # Uncomment this line to disable Python-style comments but still allow C-style comments - # self.commentGrammars = pyparsing.Or([pyparsing.cStyleComment]) - # Create command aliases which are shorter self.shortcuts.update({'$': 'aprint', '%': 'oprint'}) - # Make sure to call this super class __init__ *after* setting commentGrammars and/or updating shortcuts + # Make sure to call this super class __init__ *after* setting and/or updating shortcuts super().__init__() # NOTE: It is critical that the super class __init__ method be called AFTER updating certain parameters which # are not settable at runtime. This includes the shortcuts, multiline_commands, etc. |