cmd/abigen: allow using abigen --pkg flag with standard input (#19207)

This commit is contained in:
Vitaly Bogdanov 2019-05-27 21:28:17 +03:00 committed by Guillaume Ballet
parent c4de228e18
commit 5429dc75bd

View File

@ -81,7 +81,7 @@ func main() {
bins []string bins []string
types []string types []string
) )
if *solFlag != "" || *vyFlag != "" || (*abiFlag == "-" && *pkgFlag == "") { if *solFlag != "" || *vyFlag != "" || *abiFlag == "-" {
// Generate the list of types to exclude from binding // Generate the list of types to exclude from binding
exclude := make(map[string]bool) exclude := make(map[string]bool)
for _, kind := range strings.Split(*excFlag, ",") { for _, kind := range strings.Split(*excFlag, ",") {
@ -129,13 +129,8 @@ func main() {
} }
} else { } else {
// Otherwise load up the ABI, optional bytecode and type name from the parameters // Otherwise load up the ABI, optional bytecode and type name from the parameters
var abi []byte abi, err := ioutil.ReadFile(*abiFlag)
var err error
if *abiFlag == "-" {
abi, err = ioutil.ReadAll(os.Stdin)
} else {
abi, err = ioutil.ReadFile(*abiFlag)
}
if err != nil { if err != nil {
fmt.Printf("Failed to read input ABI: %v\n", err) fmt.Printf("Failed to read input ABI: %v\n", err)
os.Exit(-1) os.Exit(-1)