Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/flags/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func runCreate(cmd *cobra.Command, args []string) error {
viper.GetString("baseUri"),
)

// rebind flag to this subcommand
viper.BindPFlag("projKey", cmd.Flags().Lookup("projKey"))

var data inputData
err := json.Unmarshal([]byte(cmd.Flags().Lookup("data").Value.String()), &data)
// err := json.Unmarshal([]byte(viper.GetString("data")), &data)
Expand Down
3 changes: 3 additions & 0 deletions cmd/flags/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func runUpdate(cmd *cobra.Command, args []string) error {
viper.GetString("baseUri"),
)

// rebind flag to this subcommand
viper.BindPFlag("projKey", cmd.Flags().Lookup("projKey"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we basically rebinding it before we pass the data in?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess somewhere in the issue you linked I saw that since these are "local flags" for a subcommand they get overwritten

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a helper function that rebinds all the flags were going to use/re-use or something since we're going to have a lot of subcommands.


var patch []ldapi.PatchOperation
// err := json.Unmarshal([]byte(viper.GetString("data")), &patch)
err := json.Unmarshal([]byte(cmd.Flags().Lookup("data").Value.String()), &patch)
Expand Down