69
69
)
70
70
71
71
from rich .console import Group
72
+ from rich .text import Text
72
73
73
74
from . import (
74
75
ansi ,
@@ -3369,37 +3370,23 @@ def _build_alias_create_parser(cls) -> Cmd2ArgumentParser:
3369
3370
alias_create_description = "Create or overwrite an alias."
3370
3371
alias_create_parser = argparse_custom .DEFAULT_ARGUMENT_PARSER (description = alias_create_description )
3371
3372
3372
- # Create Notes TextGroup
3373
+ # Add Notes epilog
3373
3374
alias_create_notes = Group (
3374
3375
"If you want to use redirection, pipes, or terminators in the value of the alias, then quote them." ,
3375
3376
"\n " ,
3377
+ Text (" alias create save_results print_results \" >\" out.txt\n " , style = "cmd2.example" ),
3376
3378
(
3377
3379
"Since aliases are resolved during parsing, tab completion will function as it would "
3378
3380
"for the actual command the alias resolves to."
3379
3381
),
3380
3382
)
3381
- notes_group = alias_create_parser .create_text_group ("Notes" , alias_create_notes )
3382
-
3383
- # Create Examples TextGroup
3384
- alias_create_examples = Group (
3385
- "alias create ls !ls -lF" ,
3386
- "alias create show_log !cat \" log file.txt\" " ,
3387
- "alias create save_results print_results \" >\" out.txt" ,
3388
- )
3389
- examples_group = alias_create_parser .create_text_group ("Examples" , alias_create_examples )
3390
-
3391
- # Display both Notes and Examples in the epilog
3392
- alias_create_parser .epilog = Group (
3393
- notes_group ,
3394
- "\n " ,
3395
- examples_group ,
3396
- )
3383
+ alias_create_parser .epilog = alias_create_parser .create_text_group ("Notes" , alias_create_notes )
3397
3384
3398
3385
# Add arguments
3399
3386
alias_create_parser .add_argument ('name' , help = 'name of this alias' )
3400
3387
alias_create_parser .add_argument (
3401
3388
'command' ,
3402
- help = 'what the alias resolves to ' ,
3389
+ help = 'command, alias, or macro to run ' ,
3403
3390
choices_provider = cls ._get_commands_aliases_and_macros_for_completion ,
3404
3391
)
3405
3392
alias_create_parser .add_argument (
@@ -3600,15 +3587,19 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
3600
3587
"\n " ,
3601
3588
"The following creates a macro called my_macro that expects two arguments:" ,
3602
3589
"\n " ,
3603
- " macro create my_macro make_dinner --meat {1} --veggie {2}" ,
3590
+ Text ( " macro create my_macro make_dinner --meat {1} --veggie {2}" , style = "cmd2.example" ) ,
3604
3591
"\n " ,
3605
3592
"When the macro is called, the provided arguments are resolved and the assembled command is run. For example:" ,
3606
3593
"\n " ,
3607
- " my_macro beef broccoli ---> make_dinner --meat beef --veggie broccoli" ,
3594
+ Text .assemble (
3595
+ (" my_macro beef broccoli" , "cmd2.example" ),
3596
+ (" ───> " , "bold" ),
3597
+ ("make_dinner --meat beef --veggie broccoli" , "cmd2.example" ),
3598
+ ),
3608
3599
)
3609
3600
macro_create_parser = argparse_custom .DEFAULT_ARGUMENT_PARSER (description = macro_create_description )
3610
3601
3611
- # Create Notes TextGroup
3602
+ # Add Notes epilog
3612
3603
macro_create_notes = Group (
3613
3604
"To use the literal string {1} in your command, escape it this way: {{1}}." ,
3614
3605
"\n " ,
@@ -3619,15 +3610,15 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
3619
3610
"first argument will populate both {1} instances."
3620
3611
),
3621
3612
"\n " ,
3622
- " macro create ft file_taxes -p {1} -q {2} -r {1}" ,
3613
+ Text ( " macro create ft file_taxes -p {1} -q {2} -r {1}" , style = "cmd2.example" ) ,
3623
3614
"\n " ,
3624
3615
"To quote an argument in the resolved command, quote it during creation." ,
3625
3616
"\n " ,
3626
- " macro create backup !cp \" {1}\" \" {1}.orig\" " ,
3617
+ Text ( " macro create backup !cp \" {1}\" \" {1}.orig\" " , style = "cmd2.example" ) ,
3627
3618
"\n " ,
3628
3619
"If you want to use redirection, pipes, or terminators in the value of the macro, then quote them." ,
3629
3620
"\n " ,
3630
- " macro create show_results print_results -type {1} \" |\" less" ,
3621
+ Text ( " macro create show_results print_results -type {1} \" |\" less" , style = "cmd2.example" ) ,
3631
3622
"\n " ,
3632
3623
(
3633
3624
"Since macros don't resolve until after you press Enter, their arguments tab complete as paths. "
@@ -3640,7 +3631,7 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
3640
3631
macro_create_parser .add_argument ('name' , help = 'name of this macro' )
3641
3632
macro_create_parser .add_argument (
3642
3633
'command' ,
3643
- help = 'what the macro resolves to ' ,
3634
+ help = 'command, alias, or macro to run ' ,
3644
3635
choices_provider = cls ._get_commands_aliases_and_macros_for_completion ,
3645
3636
)
3646
3637
macro_create_parser .add_argument (
@@ -5147,13 +5138,14 @@ def _generate_transcript(
5147
5138
5148
5139
@classmethod
5149
5140
def _build_edit_parser (cls ) -> Cmd2ArgumentParser :
5150
- from rich .markdown import Markdown
5151
-
5152
5141
edit_description = "Run a text editor and optionally open a file with it."
5153
5142
edit_parser = argparse_custom .DEFAULT_ARGUMENT_PARSER (description = edit_description )
5154
5143
edit_parser .epilog = edit_parser .create_text_group (
5155
5144
"Note" ,
5156
- Markdown ("To set a new editor, run: `set editor <program>`" ),
5145
+ Text .assemble (
5146
+ "To set a new editor, run: " ,
5147
+ ("set editor <program>" , "cmd2.example" ),
5148
+ ),
5157
5149
)
5158
5150
5159
5151
edit_parser .add_argument (
0 commit comments