-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
81 lines (71 loc) · 2.03 KB
/
main.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
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
"""
``clang_tools.main``
--------------------
The module containing main entrypoint function.
"""
import argparse
from .install import install_clang_tools, uninstall_clang_tools
from . import RESET_COLOR, YELLOW
def get_parser() -> argparse.ArgumentParser:
"""Get and parser to interpret CLI args."""
parser = argparse.ArgumentParser()
parser.add_argument(
"-i",
"--install",
metavar="VERSION",
help="Install clang-tools about a specific version.",
)
parser.add_argument(
"-t",
"--tool",
nargs='+',
default=['clang-format', 'clang-tidy'],
metavar="TOOL",
help="Specify which tool(s) to install.",
)
parser.add_argument(
"-d",
"--directory",
default="",
metavar="DIR",
help="The directory where the clang-tools are installed.",
)
parser.add_argument(
"-f",
"--overwrite",
action="store_true",
help="Force overwriting the symlink to the installed binary. This will only "
"overwrite an existing symlink.",
)
parser.add_argument(
"-b",
"--no-progress-bar",
action="store_true",
help="Do not display a progress bar for downloads.",
)
parser.add_argument(
"-u",
"--uninstall",
metavar="VERSION",
help="Uninstall clang-tools with specific version. "
"This is done before any install.",
)
return parser
def main():
"""The main entrypoint to the CLI program."""
parser = get_parser()
args = parser.parse_args()
if args.uninstall:
uninstall_clang_tools(args.uninstall, args.directory)
if args.install:
install_clang_tools(
args.install, args.tool, args.directory, args.overwrite, args.no_progress_bar
)
else:
print(
f"{YELLOW}Nothing to do because `--install` and `--uninstall`",
f"was not specified.{RESET_COLOR}"
)
parser.print_help()
if __name__ == "__main__":
main()