Skip to content

Commit

Permalink
fix(global): fix global options parsing (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrogers committed Mar 5, 2021
1 parent 084af37 commit 122a62a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/analysis/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var getCmd = &cobra.Command{
Short: "",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
globals, _ := options.Globals(cmd)
globals, _ := options.Globals(cmd.Root())

kc := kayenta.NewDefaultClient(kayenta.ClientBaseURL(globals.KayentaURL))
executionID := args[0]
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ var rootCmd = &cobra.Command{
Short: "",
Long: ``,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if err := initLogs(verbosity); err != nil {
globals, _ := options.Globals(cmd)
if err := initLogs(globals.Verbosity); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -77,7 +78,6 @@ func Execute() {
func init() {
analysis.Configure(rootCmd)
accounts.Configure(rootCmd)
rootCmd.AddCommand()
// global options are added by an external pacakge so that they can be
// managed from a single source and used across all sub-commands. this
// ensures that the logic for getting then stays consistent
Expand Down
2 changes: 1 addition & 1 deletion internal/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type GlobalOptions struct {
}

func Globals(cmd *cobra.Command) (*GlobalOptions, error) {
flags := cmd.PersistentFlags()
flags := cmd.Root().PersistentFlags()

kayentaURL, _ := flags.GetString("kayenta-url")
verbosity, _ := flags.GetString("verbosity")
Expand Down

0 comments on commit 122a62a

Please sign in to comment.