You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/argument_processing.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,12 @@ By default, `cmd2` uses the docstring of the command method when a user asks for
80
80
command. When you use the `@with_argparser` decorator, the docstring for the `do_*` method is used
81
81
to set the description for the `argparse.ArgumentParser`.
82
82
83
+
!!! tip "description and epilog fields are rich objects"
84
+
85
+
While the `help` text itself is simply a string, both the `description` and `epilog` can contain
86
+
[rich](https://github.com/Textualize/rich) objects. For the `description` and `epilog` fields, you can pass
87
+
in any `rich` object, including Text, Tables, Markdown.
88
+
83
89
With this code:
84
90
85
91
```py
@@ -174,7 +180,32 @@ This command cannot generate tags with no content, like <br/>
174
180
175
181
!!! warning
176
182
177
-
If a command **foo** is decorated with `cmd2`'s `with_argparse` decorator, then **help_foo** will not be invoked when `help foo` is called. The [argparse](https://docs.python.org/3/library/argparse.html) module provides a rich API which can be used to tweak every aspect of the displayed help and we encourage `cmd2` developers to utilize that.
183
+
If a command **foo** is decorated with `cmd2`'s `with_argparse` decorator, then **help_foo** will not be
184
+
invoked when `help foo` is called. The [argparse](https://docs.python.org/3/library/argparse.html) module
185
+
provides a rich API which can be used to tweak every aspect of the displayed help and we encourage `cmd2`
186
+
developers to utilize that.
187
+
188
+
### Argparse HelpFormatter classes
189
+
190
+
`cmd2` has 5 different Argparse HelpFormatter classes, all of which are based on the
191
+
`RichHelpFormatter` class from [rich-argparse](https://github.com/hamdanal/rich-argparse). The
192
+
benefit is that your `cmd2` applications now have more aesthetically pleasing help which includes
193
+
color to make it quicker and easier to visually parse help text. This works for all supported
194
+
versions of Python.
195
+
196
+
-[Cmd2HelpFormatter][cmd2.argparse_custom.Cmd2HelpFormatter] - default help formatter class
0 commit comments