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 gzliudan committed Jan 7, 2025
1 parent 31bd094 commit 80f8518
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 @@ -56,7 +56,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 @@ -155,9 +155,18 @@ func abigen(c *cli.Context) error {
var contracts map[string]*compiler.Contract

if c.IsSet(jsonFlag.Name) {
jsonOutput, err := os.ReadFile(c.String(jsonFlag.Name))
var (
input = c.String(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 80f8518

Please sign in to comment.