Skip to content

Commit

Permalink
add bool flag in custom command which was ignored before (#807)
Browse files Browse the repository at this point in the history
Signed-off-by: Pulak Kanti Bhowmick <[email protected]>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>
  • Loading branch information
3 people authored Dec 5, 2024
1 parent 0ea2472 commit 39389a2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,20 @@ func executeCustomCommand(

// Prepare template data for flags
flags := cmd.Flags()
flagsData := map[string]string{}
flagsData := map[string]any{}
for _, fl := range commandConfig.Flags {
if fl.Type == "" || fl.Type == "string" {
providedFlag, err := flags.GetString(fl.Name)
if err != nil {
u.LogErrorAndExit(cliConfig, err)
}
flagsData[fl.Name] = providedFlag
} else if fl.Type == "bool" {
boolFlag, err := flags.GetBool(fl.Name)
if err != nil {
u.LogErrorAndExit(cliConfig, err)
}
flagsData[fl.Name] = boolFlag
}
}

Expand Down

0 comments on commit 39389a2

Please sign in to comment.