mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
cmd/abigen: accept combined-json via stdin (#24960)
This commit is contained in:
parent
04fabd63a4
commit
c4308f0fbc
1 changed files with 12 additions and 3 deletions
|
|
@ -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",
|
||||
|
|
@ -165,9 +165,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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue