Skip to content

Commit 621cd56

Browse files
committed
fix: validate plot_congestion.py CLI arguments
1 parent 7a3f3d5 commit 621cd56

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

flow/util/plot_congestion.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,29 @@
44
import re
55
import os
66

7+
def usage(script):
8+
print(
9+
f"Usage: {script} <sweep_name> <output_png> <congestion_file...> <sweep_value...>",
10+
file=sys.stderr,
11+
)
12+
print(
13+
"Provide an even number of trailing arguments split equally between files and values.",
14+
file=sys.stderr,
15+
)
16+
17+
18+
if len(sys.argv) < 5:
19+
usage(sys.argv[0])
20+
sys.exit(2)
21+
722
sweep = sys.argv[1]
823
output = sys.argv[2]
924
remainder = sys.argv[3:]
25+
if len(remainder) % 2 != 0:
26+
print("Error: trailing arguments must be an even count.", file=sys.stderr)
27+
usage(sys.argv[0])
28+
sys.exit(2)
29+
1030
files = remainder[: len(remainder) // 2]
1131
values = remainder[len(remainder) // 2 :]
1232

0 commit comments

Comments
 (0)