Skip to content

Commit 035de35

Browse files
authored
Merge pull request foundry-rs#619 from Tudmotu/vm.py-add-args
Add `--from` option to vm.py, to generate Vm.sol from json file
2 parents 4e5f46a + 7c11c84 commit 035de35

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

scripts/vm.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/usr/bin/env python3
22

3+
import argparse
34
import copy
45
import json
56
import re
67
import subprocess
78
from enum import Enum as PyEnum
9+
from pathlib import Path
810
from typing import Callable
911
from urllib import request
1012

@@ -26,7 +28,16 @@
2628

2729

2830
def main():
29-
json_str = request.urlopen(CHEATCODES_JSON_URL).read().decode("utf-8")
31+
parser = argparse.ArgumentParser(
32+
description="Generate Vm.sol based on the cheatcodes json created by Foundry")
33+
parser.add_argument(
34+
"--from",
35+
metavar="PATH",
36+
dest="path",
37+
required=False,
38+
help="path to a json file containing the Vm interface, as generated by Foundry")
39+
args = parser.parse_args()
40+
json_str = request.urlopen(CHEATCODES_JSON_URL).read().decode("utf-8") if args.path is None else Path(args.path).read_text()
3041
contract = Cheatcodes.from_json(json_str)
3142

3243
ccs = contract.cheatcodes

0 commit comments

Comments
 (0)