-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbutler.py
More file actions
49 lines (40 loc) · 1.62 KB
/
Copy pathbutler.py
File metadata and controls
49 lines (40 loc) · 1.62 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
import argparse
from src.commands.database.command import CommandDatabase
from src.commands.process.command import CommandProcess
from src.commands.report.command import CommandReport
from src.commands.secrets_and_variables.command import CommandSecretsAndVariables
from src.libs.utils import Utils
from src.libs.exceptions import InvalidCommandLine
from src.commands.download.command import CommandDownload
__VERSION__ = '0.12.0'
commands = {
'download': CommandDownload,
'database': CommandDatabase,
'process': CommandProcess,
'report': CommandReport,
'secrets_and_vars': CommandSecretsAndVariables
}
parser = argparse.ArgumentParser(prog="butler", description=f"Butler - GitHub Actions Oversight v{__VERSION__}")
subparsers = parser.add_subparsers(dest="command")
for name, command in commands.items():
command.load_command_line(subparsers)
args = parser.parse_args()
if args.command is None:
parser.print_help()
exit(1)
logger = Utils.init_logger(args.verbose if 'verbose' in args else None, args.very_verbose if 'very_verbose' in args else None)
try:
command = commands[args.command](logger)
if not command.run(args):
logger.warning("Execution did not return a success status, please review the logs manually")
exit(1)
exit(0)
except InvalidCommandLine as e:
logger.critical(e)
except Exception as e:
# Only show trace for Exceptions that _we_ didn't raise.
logger.opt(exception=e).trace(e)
logger.critical(e)
if not Utils.is_logging_debug_or_trace(logger):
logger.critical("To see more details about this error, run the same command using -vv")
exit(1)