Skip to content

Commit

Permalink
Merge pull request #2578 from OffchainLabs/footguns-minus-one
Browse files Browse the repository at this point in the history
Expand all --dev flags in place
  • Loading branch information
tsahee authored Aug 20, 2024
2 parents 40601f7 + 7607bf0 commit 75f3aaf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/util/confighelpers/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/knadh/koanf"
"github.com/knadh/koanf/parsers/json"
koanfjson "github.com/knadh/koanf/parsers/json"
"github.com/knadh/koanf/providers/confmap"
"github.com/knadh/koanf/providers/env"
"github.com/knadh/koanf/providers/file"
Expand Down Expand Up @@ -215,15 +214,17 @@ func devFlagArgs() []string {
}

func BeginCommonParse(f *flag.FlagSet, args []string) (*koanf.Koanf, error) {
var expandedArgs []string
for _, arg := range args {
if arg == "--version" || arg == "-v" {
return nil, ErrVersion
} else if arg == "--dev" {
args = devFlagArgs()
break
expandedArgs = append(expandedArgs, devFlagArgs()...)
} else {
expandedArgs = append(expandedArgs, arg)
}
}
if err := f.Parse(args); err != nil {
if err := f.Parse(expandedArgs); err != nil {
return nil, err
}

Expand Down Expand Up @@ -305,7 +306,7 @@ func DumpConfig(k *koanf.Koanf, extraOverrideFields map[string]interface{}) erro
return fmt.Errorf("error removing extra parameters before dump: %w", err)
}

c, err := k.Marshal(koanfjson.Parser())
c, err := k.Marshal(json.Parser())
if err != nil {
return fmt.Errorf("unable to marshal config file to JSON: %w", err)
}
Expand Down

0 comments on commit 75f3aaf

Please sign in to comment.