generated from LioQing/python-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (56 loc) · 1.64 KB
/
main.py
File metadata and controls
68 lines (56 loc) · 1.64 KB
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
import argparse
import game.main
import track.main
import train.main
DESCRIPTION = "Main entry point for the program"
def configure_parser(parser: argparse.ArgumentParser):
"""
Configure the parser for the program
:param parser: The parser to configure
:return: None
"""
subparsers = parser.add_subparsers(
dest="mode",
help="The mode to run in",
required=True,
)
# Add game parser
game_parser = subparsers.add_parser(
"game",
help="Run in gameplay mode",
description=game.main.DESCRIPTION,
formatter_class=argparse.RawTextHelpFormatter,
)
game.main.configure_parser(game_parser)
# Add track parser
track_parser = subparsers.add_parser(
"track",
help="Run in track editor mode",
description=track.main.DESCRIPTION,
formatter_class=argparse.RawTextHelpFormatter,
)
track.main.configure_parser(track_parser)
# Add train parser
train_parser = subparsers.add_parser(
"train",
help="Run in training mode",
description=train.main.DESCRIPTION,
formatter_class=argparse.RawTextHelpFormatter,
)
train.main.configure_parser(train_parser)
def main():
"""
Main entry point for the program
:return: None
"""
parser = argparse.ArgumentParser(description=DESCRIPTION)
configure_parser(parser)
args = parser.parse_args()
if args.mode == "game":
game.main.main_scene(args)
elif args.mode == "track":
track.main.main_scene(args)
elif args.mode == "train":
train.main.main_scene(args)
if __name__ == "__main__":
main()