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 cp-wjhan committed Jun 2, 2023
1 parent 71fef80 commit 4d383b1
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 4d383b1

Please sign in to comment.