Skip to content

Commit

Permalink
cmd/abigen: accept combined-json via stdin (ethereum#24960)
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman authored and jagdeep sidhu committed May 31, 2022
1 parent b2d1a9e commit 68e670a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmd/abigen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var (
}
jsonFlag = cli.StringFlag{
Name: "combined-json",
Usage: "Path to the combined-json file generated by compiler",
Usage: "Path to the combined-json file generated by compiler, - for STDIN",
}
excFlag = cli.StringFlag{
Name: "exc",
Expand Down Expand Up @@ -165,9 +165,18 @@ func abigen(c *cli.Context) error {
var contracts map[string]*compiler.Contract

if c.GlobalIsSet(jsonFlag.Name) {
jsonOutput, err := os.ReadFile(c.GlobalString(jsonFlag.Name))
var (
input = c.GlobalString(jsonFlag.Name)
jsonOutput []byte
err error
)
if input == "-" {
jsonOutput, err = io.ReadAll(os.Stdin)
} else {
jsonOutput, err = os.ReadFile(input)
}
if err != nil {
utils.Fatalf("Failed to read combined-json from compiler: %v", err)
utils.Fatalf("Failed to read combined-json: %v", err)
}
contracts, err = compiler.ParseCombinedJSON(jsonOutput, "", "", "", "")
if err != nil {
Expand Down

0 comments on commit 68e670a

Please sign in to comment.