8080 plugin ,
8181 rich_utils ,
8282 string_utils ,
83- styles ,
8483 utils ,
8584)
8685from .argparse_custom import (
142141 strip_quotes ,
143142 strip_style ,
144143)
144+ from .styles import Cmd2Style
145145
146146# NOTE: When using gnureadline with Python 3.13, start_ipython needs to be imported before any readline-related stuff
147147with contextlib .suppress (ImportError ):
169169
170170# Set up readline
171171if rl_type == RlType .NONE : # pragma: no cover
172- Cmd2Console (sys .stderr ).print (rl_warning , style = styles .WARNING )
172+ Cmd2Console (sys .stderr ).print (rl_warning , style = Cmd2Style .WARNING )
173173else :
174174 from .rl_utils import ( # type: ignore[attr-defined]
175175 readline ,
@@ -1292,7 +1292,7 @@ def perror(
12921292 * objects : Any ,
12931293 sep : str = " " ,
12941294 end : str = "\n " ,
1295- style : StyleType | None = styles .ERROR ,
1295+ style : StyleType | None = Cmd2Style .ERROR ,
12961296 soft_wrap : bool | None = None ,
12971297 rich_print_kwargs : RichPrintKwargs | None = None ,
12981298 ** kwargs : Any , # noqa: ARG002
@@ -1302,7 +1302,7 @@ def perror(
13021302 :param objects: objects to print
13031303 :param sep: string to write between print data. Defaults to " ".
13041304 :param end: string to write at end of print data. Defaults to a newline.
1305- :param style: optional style to apply to output. Defaults to styles .ERROR.
1305+ :param style: optional style to apply to output. Defaults to Cmd2Style .ERROR.
13061306 :param soft_wrap: Enable soft wrap mode. If True, text lines will not be automatically word-wrapped to fit the
13071307 terminal width; instead, any text that doesn't fit will run onto the following line(s),
13081308 similar to the built-in print() function. Set to False to enable automatic word-wrapping.
@@ -1332,7 +1332,7 @@ def psuccess(
13321332 rich_print_kwargs : RichPrintKwargs | None = None ,
13331333 ** kwargs : Any , # noqa: ARG002
13341334 ) -> None :
1335- """Wrap poutput, but apply styles .SUCCESS.
1335+ """Wrap poutput, but apply Cmd2Style .SUCCESS.
13361336
13371337 :param objects: objects to print
13381338 :param sep: string to write between print data. Defaults to " ".
@@ -1351,7 +1351,7 @@ def psuccess(
13511351 * objects ,
13521352 sep = sep ,
13531353 end = end ,
1354- style = styles .SUCCESS ,
1354+ style = Cmd2Style .SUCCESS ,
13551355 soft_wrap = soft_wrap ,
13561356 rich_print_kwargs = rich_print_kwargs ,
13571357 )
@@ -1365,7 +1365,7 @@ def pwarning(
13651365 rich_print_kwargs : RichPrintKwargs | None = None ,
13661366 ** kwargs : Any , # noqa: ARG002
13671367 ) -> None :
1368- """Wrap perror, but apply styles .WARNING.
1368+ """Wrap perror, but apply Cmd2Style .WARNING.
13691369
13701370 :param objects: objects to print
13711371 :param sep: string to write between print data. Defaults to " ".
@@ -1384,7 +1384,7 @@ def pwarning(
13841384 * objects ,
13851385 sep = sep ,
13861386 end = end ,
1387- style = styles .WARNING ,
1387+ style = Cmd2Style .WARNING ,
13881388 soft_wrap = soft_wrap ,
13891389 rich_print_kwargs = rich_print_kwargs ,
13901390 )
@@ -1415,7 +1415,7 @@ def pexcept(
14151415
14161416 if not self .debug and 'debug' in self .settables :
14171417 warning = "\n To enable full traceback, run the following command: 'set debug true'"
1418- final_msg .append (warning , style = styles .WARNING )
1418+ final_msg .append (warning , style = Cmd2Style .WARNING )
14191419
14201420 if final_msg :
14211421 self .perror (
@@ -2491,7 +2491,7 @@ def complete( # type: ignore[override]
24912491 sys .stdout ,
24922492 Text .assemble (
24932493 "\n " ,
2494- (err_str , styles .ERROR if ex .apply_style else "" ),
2494+ (err_str , Cmd2Style .ERROR if ex .apply_style else "" ),
24952495 ),
24962496 )
24972497 rl_force_redisplay ()
@@ -3591,7 +3591,7 @@ def _build_alias_create_parser(cls) -> Cmd2ArgumentParser:
35913591 alias_create_notes = Group (
35923592 "If you want to use redirection, pipes, or terminators in the value of the alias, then quote them." ,
35933593 "\n " ,
3594- Text (" alias create save_results print_results \" >\" out.txt\n " , style = styles .EXAMPLE ),
3594+ Text (" alias create save_results print_results \" >\" out.txt\n " , style = Cmd2Style .EXAMPLE ),
35953595 (
35963596 "Since aliases are resolved during parsing, tab completion will function as it would "
35973597 "for the actual command the alias resolves to."
@@ -3804,14 +3804,14 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
38043804 "\n " ,
38053805 "The following creates a macro called my_macro that expects two arguments:" ,
38063806 "\n " ,
3807- Text (" macro create my_macro make_dinner --meat {1} --veggie {2}" , style = styles .EXAMPLE ),
3807+ Text (" macro create my_macro make_dinner --meat {1} --veggie {2}" , style = Cmd2Style .EXAMPLE ),
38083808 "\n " ,
38093809 "When the macro is called, the provided arguments are resolved and the assembled command is run. For example:" ,
38103810 "\n " ,
38113811 Text .assemble (
3812- (" my_macro beef broccoli" , styles .EXAMPLE ),
3812+ (" my_macro beef broccoli" , Cmd2Style .EXAMPLE ),
38133813 (" ───> " , Style (bold = True )),
3814- ("make_dinner --meat beef --veggie broccoli" , styles .EXAMPLE ),
3814+ ("make_dinner --meat beef --veggie broccoli" , Cmd2Style .EXAMPLE ),
38153815 ),
38163816 )
38173817 macro_create_parser = argparse_custom .DEFAULT_ARGUMENT_PARSER (description = macro_create_description )
@@ -3827,15 +3827,15 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
38273827 "first argument will populate both {1} instances."
38283828 ),
38293829 "\n " ,
3830- Text (" macro create ft file_taxes -p {1} -q {2} -r {1}" , style = styles .EXAMPLE ),
3830+ Text (" macro create ft file_taxes -p {1} -q {2} -r {1}" , style = Cmd2Style .EXAMPLE ),
38313831 "\n " ,
38323832 "To quote an argument in the resolved command, quote it during creation." ,
38333833 "\n " ,
3834- Text (" macro create backup !cp \" {1}\" \" {1}.orig\" " , style = styles .EXAMPLE ),
3834+ Text (" macro create backup !cp \" {1}\" \" {1}.orig\" " , style = Cmd2Style .EXAMPLE ),
38353835 "\n " ,
38363836 "If you want to use redirection, pipes, or terminators in the value of the macro, then quote them." ,
38373837 "\n " ,
3838- Text (" macro create show_results print_results -type {1} \" |\" less" , style = styles .EXAMPLE ),
3838+ Text (" macro create show_results print_results -type {1} \" |\" less" , style = Cmd2Style .EXAMPLE ),
38393839 "\n " ,
38403840 (
38413841 "Since macros don't resolve until after you press Enter, their arguments tab complete as paths. "
@@ -4125,7 +4125,7 @@ def print_topics(self, header: str, cmds: list[str] | None, cmdlen: int, maxcol:
41254125 """
41264126 if cmds :
41274127 header_grid = Table .grid ()
4128- header_grid .add_row (header , style = styles .HELP_TITLE )
4128+ header_grid .add_row (header , style = Cmd2Style .HELP_TITLE )
41294129 if self .ruler :
41304130 header_grid .add_row (Rule (characters = self .ruler ))
41314131 self .poutput (header_grid )
@@ -4197,8 +4197,8 @@ def _help_menu(self, verbose: bool = False) -> None:
41974197 self ._print_topics (self .doc_header , cmds_doc , verbose )
41984198 else :
41994199 # Categories found, Organize all commands by category
4200- self .poutput (self .doc_leader , style = styles .HELP_HEADER , soft_wrap = False )
4201- self .poutput (self .doc_header , style = styles .HELP_HEADER , end = "\n \n " , soft_wrap = False )
4200+ self .poutput (self .doc_leader , style = Cmd2Style .HELP_HEADER , soft_wrap = False )
4201+ self .poutput (self .doc_header , style = Cmd2Style .HELP_HEADER , end = "\n \n " , soft_wrap = False )
42024202 for category in sorted (cmds_cats .keys (), key = self .default_sort_key ):
42034203 self ._print_topics (category , cmds_cats [category ], verbose )
42044204 self ._print_topics (self .default_category , cmds_doc , verbose )
@@ -4246,13 +4246,13 @@ def _print_topics(self, header: str, cmds: list[str], verbose: bool) -> None:
42464246 self .print_topics (header , cmds , 15 , 80 )
42474247 else :
42484248 category_grid = Table .grid ()
4249- category_grid .add_row (header , style = styles .HELP_TITLE )
4249+ category_grid .add_row (header , style = Cmd2Style .HELP_TITLE )
42504250 category_grid .add_row (Rule (characters = self .ruler ))
42514251 topics_table = Table (
42524252 Column ("Name" , no_wrap = True ),
42534253 Column ("Description" , overflow = "fold" ),
42544254 box = SIMPLE_HEAD ,
4255- border_style = styles .RULE_LINE ,
4255+ border_style = Cmd2Style .RULE_LINE ,
42564256 show_edge = False ,
42574257 )
42584258
@@ -4500,7 +4500,7 @@ def do_set(self, args: argparse.Namespace) -> None:
45004500 Column ("Value" , overflow = "fold" ),
45014501 Column ("Description" , overflow = "fold" ),
45024502 box = SIMPLE_HEAD ,
4503- border_style = styles .RULE_LINE ,
4503+ border_style = Cmd2Style .RULE_LINE ,
45044504 show_edge = False ,
45054505 )
45064506
@@ -5344,7 +5344,7 @@ def _build_edit_parser(cls) -> Cmd2ArgumentParser:
53445344 "Note" ,
53455345 Text .assemble (
53465346 "To set a new editor, run: " ,
5347- ("set editor <program>" , styles .EXAMPLE ),
5347+ ("set editor <program>" , Cmd2Style .EXAMPLE ),
53485348 ),
53495349 )
53505350
0 commit comments