summaryrefslogtreecommitdiff
path: root/cmd2/argparse_completer.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-27 11:30:20 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-27 11:30:20 -0400
commit0dbb4d208a51b15ca814c00d2eceb43436d15dc1 (patch)
tree0d088d2855c5b1ac0708123daa8cb67130a8ca63 /cmd2/argparse_completer.py
parent447479ecd6ef2cf01434485c4c93537c8be1a566 (diff)
downloadcmd2-git-0dbb4d208a51b15ca814c00d2eceb43436d15dc1.tar.gz
Moved cmd2.Cmd._decolorized_write() to ansi.py and renamed it to ansi_aware_write().
Diffstat (limited to 'cmd2/argparse_completer.py')
-rw-r--r--cmd2/argparse_completer.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py
index 72973bec..539132dd 100644
--- a/cmd2/argparse_completer.py
+++ b/cmd2/argparse_completer.py
@@ -66,7 +66,7 @@ import sys
from argparse import ZERO_OR_MORE, ONE_OR_MORE, ArgumentError, _, _get_action_name, SUPPRESS
from typing import List, Dict, Tuple, Callable, Union
-from .ansi import ansi_safe_wcswidth, style_error
+from .ansi import ansi_aware_write, ansi_safe_wcswidth, style_error
from .rl_utils import rl_force_redisplay
# attribute that can optionally added to an argparse argument (called an Action) to
@@ -1047,6 +1047,13 @@ class ACArgumentParser(argparse.ArgumentParser):
# determine help from format above
return formatter.format_help() + '\n'
+ def _print_message(self, message, file=None):
+ # Override _print_message to use ansi_aware_write() since we use ANSI escape characters to support color
+ if message:
+ if file is None:
+ file = _sys.stderr
+ ansi_aware_write(file, message)
+
def _get_nargs_pattern(self, action) -> str:
# Override _get_nargs_pattern behavior to use the nargs ranges provided by AutoCompleter
if isinstance(action, _RangeAction) and \