Skip to content

Commit 371284d

Browse files
committed
Merge branch 'master' into pyscript
2 parents ab8194e + a9b7121 commit 371284d

20 files changed

+753
-1083
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* Changes
2020
* ``strip_ansi()`` and ``strip_quotes()`` functions have moved to new utils module
2121
* Several constants moved to new constants module
22+
* Submenu support has been moved to a new [cmd2-submenu](https://github.com/python-cmd2/cmd2-submenu) plugin. If you use submenus, you will need to update your dependencies and modify your imports.
2223
* Deletions (potentially breaking changes)
2324
* Deleted all ``optparse`` code which had previously been deprecated in release 0.8.0
2425
* The ``options`` decorator no longer exists
@@ -28,6 +29,7 @@
2829
* Deleted ``cmd_with_subs_completer``, ``get_subcommands``, and ``get_subcommand_completer``
2930
* Replaced by default AutoCompleter implementation for all commands using argparse
3031
* Deleted support for old method of calling application commands with ``cmd()`` and ``self``
32+
* ``cmd2.redirector`` is no longer supported. Output redirection can only be done with '>' or '>>'
3133
* Python 2 no longer supported
3234
* ``cmd2`` now supports Python 3.4+
3335

cmd2/argcomplete_bridge.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
try:
55
# check if argcomplete is installed
66
import argcomplete
7-
except ImportError:
7+
except ImportError: # pragma: no cover
88
# not installed, skip the rest of the file
99
pass
1010

@@ -70,7 +70,7 @@ def tokens_for_completion(line, endidx):
7070
break
7171
except ValueError:
7272
# ValueError can be caused by missing closing quote
73-
if not quotes_to_try:
73+
if not quotes_to_try: # pragma: no cover
7474
# Since we have no more quotes to try, something else
7575
# is causing the parsing error. Return None since
7676
# this means the line is malformed.
@@ -228,15 +228,14 @@ def __call__(self, argument_parser, completer=None, always_complete_options=True
228228
output_stream.write(ifs.join(completions).encode(argcomplete.sys_encoding))
229229
elif outstr:
230230
# if there are no completions, but we got something from stdout, try to print help
231-
232231
# trick the bash completion into thinking there are 2 completions that are unlikely
233232
# to ever match.
234-
outstr = outstr.replace('\n', ' ').replace('\t', ' ').replace(' ', ' ').strip()
235-
# generate a filler entry that should always sort first
236-
filler = ' {0:><{width}}'.format('', width=len(outstr)/2)
237-
outstr = ifs.join([filler, outstr])
238233

239-
output_stream.write(outstr.encode(argcomplete.sys_encoding))
234+
comp_type = int(os.environ["COMP_TYPE"])
235+
if comp_type == 63: # type is 63 for second tab press
236+
print(outstr.rstrip(), file=argcomplete.debug_stream, end='')
237+
238+
output_stream.write(ifs.join([ifs, ' ']).encode(argcomplete.sys_encoding))
240239
else:
241240
# if completions is None we assume we don't know how to handle it so let bash
242241
# go forward with normal filesystem completion

cmd2/argparse_completer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,9 @@ def _match_argument(self, action, arg_strings_pattern):
877877

878878
return super(ACArgumentParser, self)._match_argument(action, arg_strings_pattern)
879879

880-
def _parse_known_args(self, arg_strings, namespace):
880+
# This is the official python implementation with a 5 year old patch applied
881+
# See the comment below describing the patch
882+
def _parse_known_args(self, arg_strings, namespace): # pragma: no cover
881883
# replace arg strings that are file references
882884
if self.fromfile_prefix_chars is not None:
883885
arg_strings = self._read_args_from_files(arg_strings)

0 commit comments

Comments
 (0)