6969)
7070
7171from rich .console import Group
72+ from rich .text import Text
7273
7374from . import (
7475 ansi ,
@@ -3369,37 +3370,23 @@ def _build_alias_create_parser(cls) -> Cmd2ArgumentParser:
33693370 alias_create_description = "Create or overwrite an alias."
33703371 alias_create_parser = argparse_custom .DEFAULT_ARGUMENT_PARSER (description = alias_create_description )
33713372
3372- # Create Notes TextGroup
3373+ # Add Notes epilog
33733374 alias_create_notes = Group (
33743375 "If you want to use redirection, pipes, or terminators in the value of the alias, then quote them." ,
33753376 "\n " ,
3377+ Text (" alias create save_results print_results \" >\" out.txt\n " , style = "cmd2.example" ),
33763378 (
33773379 "Since aliases are resolved during parsing, tab completion will function as it would "
33783380 "for the actual command the alias resolves to."
33793381 ),
33803382 )
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 )
33973384
33983385 # Add arguments
33993386 alias_create_parser .add_argument ('name' , help = 'name of this alias' )
34003387 alias_create_parser .add_argument (
34013388 'command' ,
3402- help = 'what the alias resolves to ' ,
3389+ help = 'command, alias, or macro to run ' ,
34033390 choices_provider = cls ._get_commands_aliases_and_macros_for_completion ,
34043391 )
34053392 alias_create_parser .add_argument (
@@ -3600,15 +3587,19 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
36003587 "\n " ,
36013588 "The following creates a macro called my_macro that expects two arguments:" ,
36023589 "\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" ) ,
36043591 "\n " ,
36053592 "When the macro is called, the provided arguments are resolved and the assembled command is run. For example:" ,
36063593 "\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+ ),
36083599 )
36093600 macro_create_parser = argparse_custom .DEFAULT_ARGUMENT_PARSER (description = macro_create_description )
36103601
3611- # Create Notes TextGroup
3602+ # Add Notes epilog
36123603 macro_create_notes = Group (
36133604 "To use the literal string {1} in your command, escape it this way: {{1}}." ,
36143605 "\n " ,
@@ -3619,15 +3610,15 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
36193610 "first argument will populate both {1} instances."
36203611 ),
36213612 "\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" ) ,
36233614 "\n " ,
36243615 "To quote an argument in the resolved command, quote it during creation." ,
36253616 "\n " ,
3626- " macro create backup !cp \" {1}\" \" {1}.orig\" " ,
3617+ Text ( " macro create backup !cp \" {1}\" \" {1}.orig\" " , style = "cmd2.example" ) ,
36273618 "\n " ,
36283619 "If you want to use redirection, pipes, or terminators in the value of the macro, then quote them." ,
36293620 "\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" ) ,
36313622 "\n " ,
36323623 (
36333624 "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:
36403631 macro_create_parser .add_argument ('name' , help = 'name of this macro' )
36413632 macro_create_parser .add_argument (
36423633 'command' ,
3643- help = 'what the macro resolves to ' ,
3634+ help = 'command, alias, or macro to run ' ,
36443635 choices_provider = cls ._get_commands_aliases_and_macros_for_completion ,
36453636 )
36463637 macro_create_parser .add_argument (
@@ -5147,13 +5138,14 @@ def _generate_transcript(
51475138
51485139 @classmethod
51495140 def _build_edit_parser (cls ) -> Cmd2ArgumentParser :
5150- from rich .markdown import Markdown
5151-
51525141 edit_description = "Run a text editor and optionally open a file with it."
51535142 edit_parser = argparse_custom .DEFAULT_ARGUMENT_PARSER (description = edit_description )
51545143 edit_parser .epilog = edit_parser .create_text_group (
51555144 "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+ ),
51575149 )
51585150
51595151 edit_parser .add_argument (
0 commit comments