1414from collections import deque
1515from typing import Dict , List , Optional , Union
1616
17+ from . import ansi
1718from . import cmd2
1819from . import utils
19- from .ansi import ansi_aware_write , ansi_safe_wcswidth , style_error
2020from .argparse_custom import ATTR_CHOICES_CALLABLE , INFINITY , generate_range_error
2121from .argparse_custom import ATTR_SUPPRESS_TAB_HINT , ATTR_DESCRIPTIVE_COMPLETION_HEADER , ATTR_NARGS_RANGE
2222from .argparse_custom import ChoicesCallable , CompletionError , CompletionItem
@@ -193,9 +193,9 @@ def update_mutex_groups(arg_action: argparse.Action) -> bool:
193193 if arg_action == completer_action :
194194 return True
195195
196- error = style_error ("\n Error: argument {}: not allowed with argument {}\n " .
197- format (argparse ._get_action_name (arg_action ),
198- argparse ._get_action_name (completer_action )))
196+ error = ansi . style_error ("\n Error: argument {}: not allowed with argument {}\n " .
197+ format (argparse ._get_action_name (arg_action ),
198+ argparse ._get_action_name (completer_action )))
199199 self ._print_message (error )
200200 return False
201201
@@ -444,11 +444,11 @@ def _format_completions(self, action, completions: List[Union[str, CompletionIte
444444 completions .sort (key = self ._cmd2_app .default_sort_key )
445445 self ._cmd2_app .matches_sorted = True
446446
447- token_width = ansi_safe_wcswidth (action .dest )
447+ token_width = ansi . ansi_safe_wcswidth (action .dest )
448448 completions_with_desc = []
449449
450450 for item in completions :
451- item_width = ansi_safe_wcswidth (item )
451+ item_width = ansi . ansi_safe_wcswidth (item )
452452 if item_width > token_width :
453453 token_width = item_width
454454
@@ -585,7 +585,7 @@ def _complete_for_arg(self, arg_action: argparse.Action,
585585 def _print_message (msg : str ) -> None :
586586 """Print a message instead of tab completions and redraw the prompt and input line"""
587587 import sys
588- ansi_aware_write (sys .stdout , msg + '\n ' )
588+ ansi . ansi_aware_write (sys .stdout , msg + '\n ' )
589589 rl_force_redisplay ()
590590
591591 def _print_arg_hint (self , arg_action : argparse .Action ) -> None :
@@ -615,7 +615,7 @@ def _print_unfinished_flag_error(self, flag_arg_state: _ArgumentState) -> None:
615615 format (argparse ._get_action_name (flag_arg_state .action ),
616616 generate_range_error (flag_arg_state .min , flag_arg_state .max ),
617617 flag_arg_state .count )
618- self ._print_message (style_error ('{}' .format (error )))
618+ self ._print_message (ansi . style_error ('{}' .format (error )))
619619
620620 def _print_completion_error (self , arg_action : argparse .Action , completion_error : CompletionError ) -> None :
621621 """
@@ -628,4 +628,4 @@ def _print_completion_error(self, arg_action: argparse.Action, completion_error:
628628
629629 error = ("\n Error tab completing {}:\n "
630630 "{}\n " .format (argparse ._get_action_name (arg_action ), indented_error ))
631- self ._print_message (style_error ('{}' .format (error )))
631+ self ._print_message (ansi . style_error ('{}' .format (error )))
0 commit comments