-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
43 lines (31 loc) · 1.35 KB
/
__init__.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
import sys
import traceback
from commands import InvalidCommandArguments, InvalidCommand, CommandException, commands
__author__ = "Christian F. (known as Chryfi)"
__copyright__ = "Copyright 2022, LectorLips"
__credits__ = ["Christian F. (known as Chryfi)", "Florian Torgau"]
__maintainer__ = "Christian F. (known as Chryfi)"
__status__ = "Release"
__version__ = "1.1"
if __name__ == "__main__":
if len(sys.argv) > 0:
commandClass = None
try:
sys.argv.pop(0)
if len(sys.argv) == 0 or (len(sys.argv) > 0 and commands.get(sys.argv[0]) is None):
raise InvalidCommand("No existing command was provided. Type in -help for a list of commands")
commandClass = commands.get(sys.argv[0])
sys.argv.pop(0)
command = commandClass(sys.argv)
command.execute()
except Exception as e:
if "-debug" in sys.argv:
print(traceback.format_exc())
print(e)
if isinstance(e, InvalidCommandArguments) and commandClass is not None:
print("\n")
print(commandClass.get_documentation())
elif not isinstance(e, InvalidCommand) and not isinstance(e, CommandException) and not "-debug" in sys.argv:
print("\nType in -debug for the stacktrace.")
quit(1)
quit(0)