From b711dc811da60c01d234e05141ca0ec3ec462a12 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 13 Dec 2024 16:31:41 +0800 Subject: [PATCH] cmd/abigen: allow using abigen --pkg flag with standard input (#19207) --- cmd/abigen/main.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go index 46a9f98719..7a696fce41 100644 --- a/cmd/abigen/main.go +++ b/cmd/abigen/main.go @@ -136,7 +136,7 @@ func abigen(c *cli.Context) error { bins []string types []string ) - if c.String(solFlag.Name) != "" || c.String(vyFlag.Name) != "" || (c.String(abiFlag.Name) == "-" && c.String(pkgFlag.Name) == "") { + if c.String(solFlag.Name) != "" || c.String(vyFlag.Name) != "" || c.String(abiFlag.Name) == "-" { // Generate the list of types to exclude from binding exclude := make(map[string]bool) for _, kind := range strings.Split(c.String(excFlag.Name), ",") { @@ -185,13 +185,8 @@ func abigen(c *cli.Context) error { } } else { // Otherwise load up the ABI, optional bytecode and type name from the parameters - var abi []byte - var err error - if c.String(abiFlag.Name) == "-" { - abi, err = io.ReadAll(os.Stdin) - } else { - abi, err = os.ReadFile(c.String(abiFlag.Name)) - } + abi, err := os.ReadFile(c.String(abiFlag.Name)) + if err != nil { fmt.Printf("Failed to read input ABI: %v\n", err) os.Exit(-1)