Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Added pflag support in cli (#11)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuvraj <[email protected]>
  • Loading branch information
yindia authored Jul 26, 2021
1 parent 2c8378c commit 0fb6560
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 97 deletions.
6 changes: 4 additions & 2 deletions flytecopilot/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,19 @@ func NewDataCommand() *cobra.Command {
return command
}

func (r *RootOptions) initConfig(_ *cobra.Command, _ []string) error {
func (r *RootOptions) initConfig(cmd *cobra.Command, _ []string) error {
r.configAccessor = viper.NewAccessor(config.Options{
StrictMode: true,
SearchPaths: []string{r.cfgFile},
})

// persistent flags were initially bound to the root command so we must bind to the same command to avoid
r.configAccessor.InitializePflags(cmd.PersistentFlags())

err := r.configAccessor.UpdateConfig(context.TODO())
if err != nil {
return err
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion flytecopilot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/aws/aws-sdk-go v1.37.1
github.com/flyteorg/flyteidl v0.18.15
github.com/flyteorg/flytestdlib v0.3.20
github.com/flyteorg/flytestdlib v0.3.30
github.com/fsnotify/fsnotify v1.4.9
github.com/ghodss/yaml v1.0.0
github.com/golang/protobuf v1.4.3
Expand Down
Loading

0 comments on commit 0fb6560

Please sign in to comment.