-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.py
executable file
·47 lines (37 loc) · 1.12 KB
/
demo.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
#!/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 ParagraphFormatter
test_cases = (
("Default", argparse.HelpFormatter),
("Paragraph", ParagraphFormatter),
)
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.
""",
formatter_class=formatter,
)
parser.add_argument(
"--arg",
help="""
This same feature would be useful for arguments that would benefit
from more explanation.
Wouldn't it?
""",
)
return parser.format_help()
for (name, formatter) in test_cases:
print("*************************")
print("Using the {} formatter".format(name))
print("*************************")
print()
print(argparse_demo(formatter))
print()