Skip to content

Commit f68d7f9

Browse files
committed
Allow to specify the path of the output file
1 parent 78a6a21 commit f68d7f9

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

route_graph/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Main part of route-graph."""
22
import ipaddress
33
import shutil
4+
from pathlib import Path
5+
from typing import Optional
46

57
import typer
68
from scapy.all import traceroute
@@ -29,8 +31,15 @@ def callback():
2931

3032

3133
@app.command()
32-
def graph(target: Annotated[str, typer.Argument(callback=validate)]):
34+
def graph(
35+
target: Annotated[str, typer.Argument(callback=validate)],
36+
path: Annotated[
37+
Optional[Path],
38+
typer.Option(help="Path to store the exported files"),
39+
] = ".",
40+
):
3341
"""Create a graph from traceroute results."""
3442
typer.echo("Collect details ...")
3543
res, unans = traceroute([target], dport=[80, 443], maxttl=20, retry=-2)
36-
res.graph(target=f"> {target}-graph.png")
44+
output_string = Path(path) / Path(f"{target}.png")
45+
res.graph(target=f"> {output_string}")

0 commit comments

Comments
 (0)