diff options
-rwxr-xr-x | README.md | 4 | ||||
-rw-r--r-- | SHLEX_TODO.txt | 2 | ||||
-rw-r--r-- | cmd2/parsing.py | 18 | ||||
-rw-r--r-- | docs/settingchanges.rst | 2 | ||||
-rw-r--r-- | docs/unfreefeatures.rst | 2 | ||||
-rwxr-xr-x | examples/arg_print.py | 2 | ||||
-rwxr-xr-x | examples/argparse_example.py | 2 | ||||
-rwxr-xr-x | examples/example.py | 2 | ||||
-rwxr-xr-x | examples/pirate.py | 2 | ||||
-rw-r--r-- | tests/test_transcript.py | 4 |
10 files changed, 20 insertions, 20 deletions
@@ -91,7 +91,7 @@ Instructions for implementing each feature follow. - Multi-line commands - Any command accepts multi-line input when its name is listed in `Cmd.multilineCommands`. + Any command accepts multi-line input when its name is listed in `Cmd.multiline_commands`. The program will keep expecting input until a line ends with any of the characters in `Cmd.terminators` . The default terminators are `;` and `/n` (empty newline). @@ -165,7 +165,7 @@ class CmdLineApp(cmd2.Cmd): MUMBLE_LAST = ['right?'] def __init__(self): - self.multilineCommands = ['orate'] + self.multiline_commands = ['orate'] self.maxrepeats = 3 # Add stuff to settable and shortcuts before calling base class initializer diff --git a/SHLEX_TODO.txt b/SHLEX_TODO.txt index b8526afa..761debee 100644 --- a/SHLEX_TODO.txt +++ b/SHLEX_TODO.txt @@ -12,7 +12,7 @@ Changelog Items: - if self.default_to_shell is true, then redirection and piping are now properly passed to the shell, previously it was truncated - object passed to do_* methods has changed. It no longer is the pyparsing object, it's a new Statement object. A side effect of this is that we now have a clean interface between the parsing logic and the rest of cmd2. If we need to change the parser in the future, we can do it without breaking anything. The parser is now self.statement_parser instead of self.command_parser. - input redirection no longer supported. Use the load command instead. -- multilineCommand attribute is no multiline_command +- multilineCommand attribute is now multiline_command - submenus now call all hooks, it used to just call precmd and postcmd - cmd2 ignores identchars. The standardlibrary cmd uses those characters to split the first "word" of the input, but cmd2 hasn't used those for a while, and the new parsing logic parses on whitespace, which has the added benefit of full unicode support, unlike cmd or prior versions of cmd2. - set_posix_shlex function and POSIX_SHLEX variable have been removed. Parsing behavior is now always posix=false. diff --git a/cmd2/parsing.py b/cmd2/parsing.py index 0ba0736d..75bbd1c4 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -66,7 +66,7 @@ class StatementParser(): else: self.terminators = terminators if multiline_commands is None: - self.multilineCommands = [] + self.multiline_commands = [] else: self.multiline_commands = multiline_commands if aliases is None: @@ -133,9 +133,9 @@ class StatementParser(): terminator = BLANK_LINE # split the input on whitespace - s = shlex.shlex(line, posix=False) - s.whitespace_split = True - tokens = self.split_on_punctuation(list(s)) + lexer = shlex.shlex(line, posix=False) + lexer.whitespace_split = True + tokens = self.split_on_punctuation(list(lexer)) # expand aliases if tokens: @@ -268,9 +268,9 @@ class StatementParser(): line = self.expand_shortcuts(line) # split the input on whitespace - s = shlex.shlex(line, posix=False) - s.whitespace_split = True - tokens = self.split_on_punctuation(list(s)) + lexer = shlex.shlex(line, posix=False) + lexer.whitespace_split = True + tokens = self.split_on_punctuation(list(lexer)) # expand aliases if tokens: @@ -304,7 +304,7 @@ class StatementParser(): """Given a command, expand any aliases for the command""" # make a copy of aliases so we can edit it tmp_aliases = list(self.aliases.keys()) - keep_expanding = len(tmp_aliases) > 0 + keep_expanding = bool(tmp_aliases) while keep_expanding: for cur_alias in tmp_aliases: @@ -312,7 +312,7 @@ class StatementParser(): if command == cur_alias: command = self.aliases[cur_alias] tmp_aliases.remove(cur_alias) - keep_expanding = len(tmp_aliases) > 0 + keep_expanding = bool(tmp_aliases) break return command diff --git a/docs/settingchanges.rst b/docs/settingchanges.rst index 539bbc9a..f005fb49 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 bcf0fa41..16d0eb08 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 diff --git a/examples/arg_print.py b/examples/arg_print.py index 18fa483f..bd8ff6be 100755 --- a/examples/arg_print.py +++ b/examples/arg_print.py @@ -30,7 +30,7 @@ class ArgumentAndOptionPrinter(cmd2.Cmd): # Make sure to call this super class __init__ *after* setting commentGrammars 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 commentGrammars, shortcuts, multilineCommands, etc. + # are not settable at runtime. This includes the shortcuts, multiline_commands, etc. def do_aprint(self, arg): """Print the argument string this basic command is called with.""" diff --git a/examples/argparse_example.py b/examples/argparse_example.py index e9b377ba..3d436323 100755 --- a/examples/argparse_example.py +++ b/examples/argparse_example.py @@ -20,7 +20,7 @@ from cmd2 import Cmd, with_argparser, with_argument_list class CmdLineApp(Cmd): """ Example cmd2 application. """ def __init__(self, ip_addr=None, port=None, transcript_files=None): - self.multilineCommands = ['orate'] + self.multiline_commands = ['orate'] self.shortcuts.update({'&': 'speak'}) self.maxrepeats = 3 diff --git a/examples/example.py b/examples/example.py index 612d81e5..35e2c49f 100755 --- a/examples/example.py +++ b/examples/example.py @@ -27,7 +27,7 @@ class CmdLineApp(Cmd): MUMBLE_LAST = ['right?'] def __init__(self): - self.multilineCommands = ['orate'] + self.multiline_commands = ['orate'] self.maxrepeats = 3 # Add stuff to settable and shortcuts before calling base class initializer diff --git a/examples/pirate.py b/examples/pirate.py index 7fe3884b..bcf9a368 100755 --- a/examples/pirate.py +++ b/examples/pirate.py @@ -14,7 +14,7 @@ class Pirate(Cmd): """A piratical example cmd2 application involving looting and drinking.""" def __init__(self): self.default_to_shell = True - self.multilineCommands = ['sing'] + self.multiline_commands = ['sing'] self.terminators = Cmd.terminators + ['...'] self.songcolor = 'blue' diff --git a/tests/test_transcript.py b/tests/test_transcript.py index bba56cab..6330ab09 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -24,7 +24,7 @@ class CmdLineApp(cmd2.Cmd): MUMBLE_LAST = ['right?'] def __init__(self, *args, **kwargs): - self.multilineCommands = ['orate'] + self.multiline_commands = ['orate'] self.maxrepeats = 3 self.redirector = '->' @@ -125,7 +125,7 @@ def test_base_with_transcript(_cmdline_app): Documented commands (type help <topic>): ======================================== -alias help load orate pyscript say shell speak +alias help load orate pyscript say shell speak edit history mumble py quit set shortcuts unalias (Cmd) help say |