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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135 | def get_parser() -> argparse.ArgumentParser:
"""
Return the CLI argument parser.
Returns:
An argparse parser.
"""
parser = argparse.ArgumentParser(
prog="dependenpy", add_help=False, description="Command line tool for dependenpy Python package."
)
mxg = parser.add_mutually_exclusive_group(required=False)
parser.add_argument(
"packages",
metavar="PACKAGES",
nargs=argparse.ONE_OR_MORE,
help="The package list. Can be a comma-separated list. Each package "
"must be either a valid path or a package in PYTHONPATH.",
)
parser.add_argument(
"-d",
"--depth",
default=None,
type=int,
dest="depth",
help="Specify matrix or graph depth. Default: best guess.",
)
parser.add_argument(
"-f", "--format", choices=FORMAT, default="text", dest="format", help="Output format. Default: text."
)
mxg.add_argument(
"-g",
"--show-graph",
action="store_true",
dest="graph",
default=False,
help="Show the graph (no text format). Default: false.",
)
parser.add_argument(
"-G",
"--greedy",
action="store_true",
dest="greedy",
default=False,
help="Explore subdirectories even if they do not contain an "
"__init__.py file. Can make execution slower. Default: false.",
)
parser.add_argument(
"-h", "--help", action="help", default=argparse.SUPPRESS, help="Show this help message and exit."
)
parser.add_argument(
"-i",
"--indent",
default=None,
type=int,
dest="indent",
help="Specify output indentation. CSV will never be indented. "
"Text will always have new-lines. JSON can be minified with "
"a negative value. Default: best guess.",
)
mxg.add_argument(
"-l",
"--show-dependencies-list",
action="store_true",
dest="dependencies",
default=False,
help="Show the dependencies list. Default: false.",
)
mxg.add_argument(
"-m",
"--show-matrix",
action="store_true",
dest="matrix",
default=False,
help="Show the matrix. Default: true unless -g, -l or -t.",
)
parser.add_argument(
"-o",
"--output",
action="store",
dest="output",
default=sys.stdout,
help="Output to given file. Default: stdout.",
)
mxg.add_argument(
"-t",
"--show-treemap",
action="store_true",
dest="treemap",
default=False,
help="Show the treemap (work in progress). Default: false.",
)
parser.add_argument(
"-v",
"--version",
action="version",
version=f"dependenpy {__version__}",
help="Show the current version of the program and exit.",
)
parser.add_argument(
"-z",
"--zero",
dest="zero",
default="0",
help="Character to use for cells with value=0 (text matrix display only).",
)
return parser
|