Skip to content

Commit 4a0821e

Browse files
committed
Split cli, persist running scenarios
* better code organisation * persist running scenarios to disk for later restore
1 parent 9091340 commit 4a0821e

File tree

13 files changed

+477
-306
lines changed

13 files changed

+477
-306
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ dependencies = [
2323
"jsonrpcserver==5.0.3",
2424
"jsonrpcclient==4.0.0",
2525
"networkx==3.1",
26+
"rich==13.5.2",
2627
"PyYAML==6.0.1",
2728
]
2829
dynamic = ["version"]
2930

3031
[project.scripts]
3132
warnet = "warnet.warnetd:run_gunicorn"
32-
warcli = "warnet.cli:cli"
33+
warcli = "warnet.cli.main:cli"
3334

3435
[tool.black]
3536
line-length = 88

src/warnet/cli.py

Lines changed: 0 additions & 286 deletions
This file was deleted.

src/warnet/cli/__init__.py

Whitespace-only changes.

src/warnet/cli/debug.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from pathlib import Path
2+
3+
import click
4+
from rich import print
5+
6+
from templates import TEMPLATES
7+
from warnet.cli.rpc import rpc_call
8+
9+
EXAMPLE_GRAPH_FILE = TEMPLATES / "example.graphml"
10+
11+
12+
@click.group(name="debug")
13+
def debug():
14+
"""Debug commands"""
15+
16+
17+
@debug.command()
18+
@click.argument("graph_file", type=str)
19+
@click.option("--network", default="warnet", show_default=True)
20+
def generate_compose(graph_file: str, network: str = "warnet"):
21+
"""
22+
Generate the docker-compose file for a given <graph_file> and <--network> (default: "warnet") name and return it.
23+
"""
24+
try:
25+
result = rpc_call(
26+
"generate_compose", {"graph_file": graph_file, "network": network}
27+
)
28+
print(result)
29+
except Exception as e:
30+
print(f"Error generating compose: {e}")
31+
32+
33+
@debug.command()
34+
@click.argument("graph_file", type=str)
35+
@click.option("--network", default="warnet", show_default=True)
36+
def update_dns_seed(graph_file: Path = EXAMPLE_GRAPH_FILE, network: str = "warnet"):
37+
"""
38+
Update the dns seed database using a <graph_file> on <--network> (default: "warnet")
39+
"""
40+
try:
41+
result = rpc_call(
42+
"update_dns_seeder", {"graph_file": str(graph_file), "network": network}
43+
)
44+
print(result)
45+
except Exception as e:
46+
print(f"Error updating dns seed addresses: {e}")

0 commit comments

Comments
 (0)