mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
abigen support for --type flag with piped data
`abigen` fails to support the `--type` flag when data is piped to it. Ethereum Issue: #17647 This change is to fix the command line processing to support a piped ABI to `abigen` and use the `--type` flag.
This commit is contained in:
parent
2d98099c25
commit
6cd053bcfe
1 changed files with 21 additions and 6 deletions
|
|
@ -75,7 +75,7 @@ func main() {
|
||||||
bins []string
|
bins []string
|
||||||
types []string
|
types []string
|
||||||
)
|
)
|
||||||
if *solFlag != "" || *abiFlag == "-" {
|
if *solFlag != "" || (*abiFlag == "-" && *pkgFlag == "") {
|
||||||
// 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, ",") {
|
||||||
|
|
@ -111,10 +111,20 @@ 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
|
||||||
abi, err := ioutil.ReadFile(*abiFlag)
|
var abi []byte
|
||||||
if err != nil {
|
var err error
|
||||||
fmt.Printf("Failed to read input ABI: %v\n", err)
|
if *abiFlag == "-" {
|
||||||
os.Exit(-1)
|
abi, err = ioutil.ReadAll(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to read input ABI from stdin: %v\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
abi, err = ioutil.ReadFile(*abiFlag)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to read input ABI: %v\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
abis = append(abis, string(abi))
|
abis = append(abis, string(abi))
|
||||||
|
|
||||||
|
|
@ -156,5 +166,10 @@ func contractsFromStdin() (map[string]*compiler.Contract, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return compiler.ParseCombinedJSON(bytes, "", "", "", "")
|
code, err := compiler.ParseCombinedJSON(bytes, "", "", "", "")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error from parse: %s\n", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return code, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue