-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflexidemo.py
executable file
·52 lines (41 loc) · 1.36 KB
/
flexidemo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python3
# Copyright (c) 2019 David Steele <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-or-later
# License-Filename: LICENSE
#
import argparse
from argparse_formatter import FlexiFormatter
test_cases = (
("Default", argparse.HelpFormatter),
("Flexi", FlexiFormatter),
)
def argparse_demo(formatter):
parser = argparse.ArgumentParser(
epilog="""
This is a multi-paragraph epilog. It is presenting data that would
benefit by being visually broken up into pieces.
It sure would be nice if it was represented that way.
1. This is a pretty long line, in a bullet list - getting longer
and longer and longer
2. this isn't
""",
formatter_class=formatter,
)
parser.add_argument(
"--arg",
help="""
This same feature would be useful for arguments that would benefit
from more explanation.
1. It looks nicer
2. It is easier to read, even if some of the bullets get to be a little long.
""", # noqa
)
return parser.format_help()
for (name, formatter) in test_cases:
print("*************************")
print("Using the {} formatter".format(name))
print("*************************")
print()
print(argparse_demo(formatter))
print()