-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtbctrl.py
More file actions
46 lines (32 loc) · 1.16 KB
/
Copy pathhtbctrl.py
File metadata and controls
46 lines (32 loc) · 1.16 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
#!/usr/bin/env python3
"""HTB Ctrl Cli."""
from __future__ import annotations
import os
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent
SRC = REPO_ROOT / "src"
if SRC.is_dir() and str(SRC) not in sys.path:
sys.path.insert(0, str(SRC))
def main(argv: list[str] | None = None) -> None:
from ctrl_cli import bootstrap as boot
argv = list(sys.argv[1:] if argv is None else argv)
if boot.should_bootstrap() and not boot.running_in_venv():
boot.ensure_runtime(quiet=True)
boot.silent_init()
venv_py = boot.venv_python()
os.execv(str(venv_py), [str(venv_py), __file__, *argv])
from ctrl_cli.argv import normalize_argv, wants_root_help
from ctrl_cli.cli import app
import typer.main
argv = normalize_argv(argv)
if wants_root_help(argv):
from ctrl_cli.argv import apply_global_argv
from ctrl_cli.ui import print_help
apply_global_argv(argv)
print_help(hide_banner="--hide-banner" in argv)
raise SystemExit(0)
cmd = typer.main.get_command(app)
cmd(prog_name="htbctrl", args=argv, standalone_mode=True)
if __name__ == "__main__":
main()