cmd/abigen: make --combined-json, --abi mutually exclusive. Require at least one of them to be set.

This commit is contained in:
jwasinger 2025-01-20 03:46:27 +08:00 committed by GitHub
parent 7c763c5e54
commit 79e091c61f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,8 +98,12 @@ func abigen(c *cli.Context) error {
if c.String(pkgFlag.Name) == "" { if c.String(pkgFlag.Name) == "" {
utils.Fatalf("No destination package specified (--pkg)") utils.Fatalf("No destination package specified (--pkg)")
} }
if c.String(abiFlag.Name) == "" { if c.String(abiFlag.Name) == "" && c.String(jsonFlag.Name) == "" {
utils.Fatalf("No contract ABI source specified (--abi)") utils.Fatalf("Either contract ABI source (--abi) or combined-json (--combined-json) are required")
}
if c.String(abiFlag.Name) != "" && c.String(jsonFlag.Name) != "" {
utils.Fatalf("contract ABI source (--abi) and combined-json (--combined-json) are mutually-exclusive")
} }
var lang bind.Lang var lang bind.Lang
switch c.String(langFlag.Name) { switch c.String(langFlag.Name) {