Open matanox opened 5 months ago
Hi @matanox,
What you say could be effectively added as a built-in feature for rich_argparse.RichHelpFormatter
(for example with an attibute newline_in_help=True
).
However, it can be achieved manually by using class_formatter = rich_argparse.RawTextRichHelpFormatter
and adding two new lines at the end of each args help:
import argparse
from rich_argparse import RawTextRichHelpFormatter
parser = argparse.ArgumentParser(
"PROG", formatter_class=RawTextRichHelpFormatter, add_help=False
)
parser.add_argument(
"-h",
"--help",
action="help",
help="show this help message and exit\n\n",
)
parser.add_argument(
"--opt1",
nargs="?",
help="opt1 help\n\n",
)
parser.add_argument(
"--opt2",
nargs="+",
help="opt2 help\n\n",
)
parser.print_help()
will have this output:
Of all aspects challenging the readability of an argparse output for the 95% of us, or making people avoid reading too much, perhaps the density of the text is one of the worst sticking points. This is because the chunking of the content is not very clear even with colors used: each option's description will begin either at the same line as the option name or on the next line ― yielding a complex layout which can IMHO be alleviated by an empty line between every pair of options, bestowing clear visual separation between the options being displayed.
Could be nice adding the option to add a line space between every pair of arguments (as well as before and after the whole output as a lesser concern).