Skip to content

Commit b727183

Browse files
committed
Improvements and typo fixes in the readme
1 parent 7a01d21 commit b727183

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

README.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ parser = argparse.ArgumentParser(..., formatter_class=RichHelpFormatter)
5353
...
5454
```
5555

56-
*rich-argparse* defines equivalents to argparse's [built-in formatters](
56+
*rich-argparse* defines equivalents to all argparse's [built-in formatters](
5757
https://docs.python.org/3/library/argparse.html#formatter-class):
5858

5959
| `rich_argparse` formatter | equivalent in `argparse` |
@@ -128,8 +128,8 @@ parser = argparse.ArgumentParser(..., formatter_class=RichHelpFormatter)
128128
### Colors in the `usage`
129129

130130
The usage **generated by the formatter** is colored using the `argparse.args` and `argparse.metavar`
131-
styles. If you use a custom `usage` message in the parser, it will treated as "plain text" and will
132-
**not** be colored by default. You can enable colors in user defined usage message through
131+
styles. If you use a custom `usage` message in the parser, it will be treated as "plain text" and
132+
will **not** be colored by default. You can enable colors in user defined usage message through
133133
[console markup](https://rich.readthedocs.io/en/stable/markup.html) by setting
134134
`RichHelpFormatter.usage_markup = True`. If you enable this option, make sure to [escape](
135135
https://rich.readthedocs.io/en/stable/markup.html#escaping) any square brackets in the usage text.
@@ -151,7 +151,7 @@ and epilog.
151151

152152
You can use any rich renderable in the descriptions and epilog. This includes all built-in rich
153153
renderables like `Table` and `Markdown` and any custom renderables defined using the
154-
[Console Protcol](https://rich.readthedocs.io/en/stable/protocol.html#console-protocol).
154+
[Console Protocol](https://rich.readthedocs.io/en/stable/protocol.html#console-protocol).
155155

156156
```python
157157
import argparse
@@ -182,9 +182,6 @@ Certain features are **disabled** for arbitrary renderables other than strings,
182182
* Styling with the `"argparse.text"` style defined in `RichHelpFormatter.styles`
183183
* Replacement of `%(prog)s` with the program name
184184

185-
Arbitrary renderables are displayed "as is" except for long runs of empty lines that get truncated
186-
to two empty lines following the behavior of argparse.
187-
188185
## Working with subparsers
189186

190187
Subparsers do not inherit the formatter class from the parent parser by default. You have to pass
@@ -231,11 +228,10 @@ COLUMNS=120 python my_cli.py --generate-help-preview # force the width of the o
231228

232229
## Working with third party formatters
233230

234-
*rich-argparse* can be used with other formatters that **do not rely on the private internals**
235-
of `argparse.HelpFormatter`. A popular example is [django](https://pypi.org/project/django) that
236-
defines a custom help formatter that is used with its built in commands as well as with extension
237-
libraries and user defined commands. To use *rich-argparse* in your django project, change your
238-
`manage.py` file as follows:
231+
*rich-argparse* can be used with other custom formatters through multiple inheritance. For example,
232+
[django](https://pypi.org/project/django) defines a custom help formatter for its built in commands
233+
as well as extension libraries and user defined commands. To use *rich-argparse* in your django
234+
project, change your `manage.py` file as follows:
239235

240236
```diff
241237
diff --git a/my_project/manage.py b/my_project/manage.py
@@ -283,8 +279,7 @@ index 7fb6855..5e5d48a 100755
283279
main()
284280
```
285281

286-
Now try out some command like `python manage.py runserver --help` and notice how the special
287-
ordering of the arguments applied by django is respected by the new help formatter.
282+
Now the output of all `python manage.py <COMMAND> --help` will be colored.
288283

289284
## Optparse support
290285

@@ -301,7 +296,7 @@ parser = optparse.OptionParser(formatter=IndentedRichHelpFormatter())
301296
...
302297
```
303298

304-
You can also generated a more helpful usage message by passing `usage=GENERATE_USAGE` to the
299+
You can also generate a more helpful usage message by passing `usage=GENERATE_USAGE` to the
305300
parser. This is similar to the default behavior of `argparse`.
306301

307302
```python
@@ -322,12 +317,10 @@ Syntax highlighting works the same as with `argparse`.
322317

323318
Colors in the `usage` are only supported when using `GENERATE_USAGE`.
324319

325-
Customizing the group name format is not supported. optparse uses Title Case format by default.
326-
327320
## Legacy Windows support
328321

329-
If your application still runs on legacy Windows versions (older than Windows 10), you'll need to
330-
enable ANSI escape sequences by calling `colorama.init()` otherwise colors will be disabled:
322+
When used on legacy Windows versions like *Windows 7*, colors are disabled unless
323+
[colorama](https://pypi.org/project/colorama/) is used:
331324

332325
```python
333326
import argparse
@@ -338,4 +331,3 @@ colorama.init()
338331
parser = argparse.ArgumentParser(..., formatter_class=RichHelpFormatter)
339332
...
340333
```
341-
This is **not** required on Windows 10 and newer or on other operating systems.

0 commit comments

Comments
 (0)