-
Notifications
You must be signed in to change notification settings - Fork 46
/
debug.py
61 lines (55 loc) · 1.83 KB
/
debug.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
"""
This script is for invoking algokit from your IDE with a dynamic set of args,
defined in args.in (which is in .gitignore)
"""
import os
import subprocess
import sys
from pathlib import Path
try:
import click
except ImportError:
print( # noqa: T201
"ERROR: Couldn't import click, make sure you've run 'poetry install' and activated the virtual environment.\n"
"For tips on getting started with developing AlgoKit CLI itself see CONTRIBUTING.md.\n",
file=sys.stderr,
)
raise
if sys.prefix == sys.base_prefix:
click.echo(
click.style(
"WARNING: virtualenv not activated, this is unexpected and you probably want to activate it first",
fg="red",
),
err=True,
)
vcs_root = Path(__file__).parent
args_file = vcs_root / "args.in"
if not args_file.exists():
click.echo(
click.style(
"arg.in does not exist, creating an empty file.\n"
"Edit this file to change what runs - each line should contain the command line arguments to algokit.\n"
"\n",
fg="yellow",
),
err=True,
)
args_file.touch(exist_ok=False)
args_file.write_text("--version")
commands_sequence = args_file.read_text().splitlines()
# change to src directory so algokit is in path
os.chdir(vcs_root / "src")
for command in commands_sequence or [""]:
click.echo(click.style(f"> algokit -v {command}", bold=True), err=True)
run_result = subprocess.run([sys.executable, "-m", "algokit", "-v", *command.split()], check=False)
if run_result.returncode != 0:
click.echo(
click.style(
f"command failed, return code was: {run_result.returncode}",
bold=True,
fg="red",
),
err=True,
)
sys.exit(run_result.returncode)