80
80
plugin ,
81
81
rich_utils ,
82
82
string_utils ,
83
- styles ,
84
83
utils ,
85
84
)
86
85
from .argparse_custom import (
142
141
strip_quotes ,
143
142
strip_style ,
144
143
)
144
+ from .styles import Cmd2Style
145
145
146
146
# NOTE: When using gnureadline with Python 3.13, start_ipython needs to be imported before any readline-related stuff
147
147
with contextlib .suppress (ImportError ):
169
169
170
170
# Set up readline
171
171
if 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 )
173
173
else :
174
174
from .rl_utils import ( # type: ignore[attr-defined]
175
175
readline ,
@@ -1292,7 +1292,7 @@ def perror(
1292
1292
* objects : Any ,
1293
1293
sep : str = " " ,
1294
1294
end : str = "\n " ,
1295
- style : StyleType | None = styles .ERROR ,
1295
+ style : StyleType | None = Cmd2Style .ERROR ,
1296
1296
soft_wrap : bool | None = None ,
1297
1297
rich_print_kwargs : RichPrintKwargs | None = None ,
1298
1298
** kwargs : Any , # noqa: ARG002
@@ -1302,7 +1302,7 @@ def perror(
1302
1302
:param objects: objects to print
1303
1303
:param sep: string to write between print data. Defaults to " ".
1304
1304
: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.
1306
1306
:param soft_wrap: Enable soft wrap mode. If True, text lines will not be automatically word-wrapped to fit the
1307
1307
terminal width; instead, any text that doesn't fit will run onto the following line(s),
1308
1308
similar to the built-in print() function. Set to False to enable automatic word-wrapping.
@@ -1332,7 +1332,7 @@ def psuccess(
1332
1332
rich_print_kwargs : RichPrintKwargs | None = None ,
1333
1333
** kwargs : Any , # noqa: ARG002
1334
1334
) -> None :
1335
- """Wrap poutput, but apply styles .SUCCESS.
1335
+ """Wrap poutput, but apply Cmd2Style .SUCCESS.
1336
1336
1337
1337
:param objects: objects to print
1338
1338
:param sep: string to write between print data. Defaults to " ".
@@ -1351,7 +1351,7 @@ def psuccess(
1351
1351
* objects ,
1352
1352
sep = sep ,
1353
1353
end = end ,
1354
- style = styles .SUCCESS ,
1354
+ style = Cmd2Style .SUCCESS ,
1355
1355
soft_wrap = soft_wrap ,
1356
1356
rich_print_kwargs = rich_print_kwargs ,
1357
1357
)
@@ -1365,7 +1365,7 @@ def pwarning(
1365
1365
rich_print_kwargs : RichPrintKwargs | None = None ,
1366
1366
** kwargs : Any , # noqa: ARG002
1367
1367
) -> None :
1368
- """Wrap perror, but apply styles .WARNING.
1368
+ """Wrap perror, but apply Cmd2Style .WARNING.
1369
1369
1370
1370
:param objects: objects to print
1371
1371
:param sep: string to write between print data. Defaults to " ".
@@ -1384,7 +1384,7 @@ def pwarning(
1384
1384
* objects ,
1385
1385
sep = sep ,
1386
1386
end = end ,
1387
- style = styles .WARNING ,
1387
+ style = Cmd2Style .WARNING ,
1388
1388
soft_wrap = soft_wrap ,
1389
1389
rich_print_kwargs = rich_print_kwargs ,
1390
1390
)
@@ -1415,7 +1415,7 @@ def pexcept(
1415
1415
1416
1416
if not self .debug and 'debug' in self .settables :
1417
1417
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 )
1419
1419
1420
1420
if final_msg :
1421
1421
self .perror (
@@ -2491,7 +2491,7 @@ def complete( # type: ignore[override]
2491
2491
sys .stdout ,
2492
2492
Text .assemble (
2493
2493
"\n " ,
2494
- (err_str , styles .ERROR if ex .apply_style else "" ),
2494
+ (err_str , Cmd2Style .ERROR if ex .apply_style else "" ),
2495
2495
),
2496
2496
)
2497
2497
rl_force_redisplay ()
@@ -3591,7 +3591,7 @@ def _build_alias_create_parser(cls) -> Cmd2ArgumentParser:
3591
3591
alias_create_notes = Group (
3592
3592
"If you want to use redirection, pipes, or terminators in the value of the alias, then quote them." ,
3593
3593
"\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 ),
3595
3595
(
3596
3596
"Since aliases are resolved during parsing, tab completion will function as it would "
3597
3597
"for the actual command the alias resolves to."
@@ -3804,14 +3804,14 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
3804
3804
"\n " ,
3805
3805
"The following creates a macro called my_macro that expects two arguments:" ,
3806
3806
"\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 ),
3808
3808
"\n " ,
3809
3809
"When the macro is called, the provided arguments are resolved and the assembled command is run. For example:" ,
3810
3810
"\n " ,
3811
3811
Text .assemble (
3812
- (" my_macro beef broccoli" , styles .EXAMPLE ),
3812
+ (" my_macro beef broccoli" , Cmd2Style .EXAMPLE ),
3813
3813
(" ───> " , Style (bold = True )),
3814
- ("make_dinner --meat beef --veggie broccoli" , styles .EXAMPLE ),
3814
+ ("make_dinner --meat beef --veggie broccoli" , Cmd2Style .EXAMPLE ),
3815
3815
),
3816
3816
)
3817
3817
macro_create_parser = argparse_custom .DEFAULT_ARGUMENT_PARSER (description = macro_create_description )
@@ -3827,15 +3827,15 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
3827
3827
"first argument will populate both {1} instances."
3828
3828
),
3829
3829
"\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 ),
3831
3831
"\n " ,
3832
3832
"To quote an argument in the resolved command, quote it during creation." ,
3833
3833
"\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 ),
3835
3835
"\n " ,
3836
3836
"If you want to use redirection, pipes, or terminators in the value of the macro, then quote them." ,
3837
3837
"\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 ),
3839
3839
"\n " ,
3840
3840
(
3841
3841
"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:
4125
4125
"""
4126
4126
if cmds :
4127
4127
header_grid = Table .grid ()
4128
- header_grid .add_row (header , style = styles .HELP_TITLE )
4128
+ header_grid .add_row (header , style = Cmd2Style .HELP_TITLE )
4129
4129
if self .ruler :
4130
4130
header_grid .add_row (Rule (characters = self .ruler ))
4131
4131
self .poutput (header_grid )
@@ -4197,8 +4197,8 @@ def _help_menu(self, verbose: bool = False) -> None:
4197
4197
self ._print_topics (self .doc_header , cmds_doc , verbose )
4198
4198
else :
4199
4199
# 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 )
4202
4202
for category in sorted (cmds_cats .keys (), key = self .default_sort_key ):
4203
4203
self ._print_topics (category , cmds_cats [category ], verbose )
4204
4204
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:
4246
4246
self .print_topics (header , cmds , 15 , 80 )
4247
4247
else :
4248
4248
category_grid = Table .grid ()
4249
- category_grid .add_row (header , style = styles .HELP_TITLE )
4249
+ category_grid .add_row (header , style = Cmd2Style .HELP_TITLE )
4250
4250
category_grid .add_row (Rule (characters = self .ruler ))
4251
4251
topics_table = Table (
4252
4252
Column ("Name" , no_wrap = True ),
4253
4253
Column ("Description" , overflow = "fold" ),
4254
4254
box = SIMPLE_HEAD ,
4255
- border_style = styles .RULE_LINE ,
4255
+ border_style = Cmd2Style .RULE_LINE ,
4256
4256
show_edge = False ,
4257
4257
)
4258
4258
@@ -4500,7 +4500,7 @@ def do_set(self, args: argparse.Namespace) -> None:
4500
4500
Column ("Value" , overflow = "fold" ),
4501
4501
Column ("Description" , overflow = "fold" ),
4502
4502
box = SIMPLE_HEAD ,
4503
- border_style = styles .RULE_LINE ,
4503
+ border_style = Cmd2Style .RULE_LINE ,
4504
4504
show_edge = False ,
4505
4505
)
4506
4506
@@ -5344,7 +5344,7 @@ def _build_edit_parser(cls) -> Cmd2ArgumentParser:
5344
5344
"Note" ,
5345
5345
Text .assemble (
5346
5346
"To set a new editor, run: " ,
5347
- ("set editor <program>" , styles .EXAMPLE ),
5347
+ ("set editor <program>" , Cmd2Style .EXAMPLE ),
5348
5348
),
5349
5349
)
5350
5350
0 commit comments