Skip to content

Commit

Permalink
Fix bug in PrintCommandLineWithCursor when flag is a slice of strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Aug 2, 2018
1 parent cddffd6 commit 2cdae17
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ func PrintCommandLineWithCursor(cmd *cobra.Command, it *vt.Iterator) {
flags := make([]string, 0)
cmd.Flags().Visit(func(flag *pflag.Flag) {
if flag.Name != "cursor" {
flags = append(flags, fmt.Sprintf("--%s=%v", flag.Name, flag.Value.String()))
var f string
switch flag.Value.Type() {
case "stringSlice":
ss, _ := cmd.Flags().GetStringSlice(flag.Name)
f = fmt.Sprintf("--%s='%s'", flag.Name, strings.Join(ss, ","))
default:
f = fmt.Sprintf("--%s=%v", flag.Name, flag.Value.String())
}
flags = append(flags, f)
}
})
flags = append(flags, fmt.Sprintf("--cursor=%s", cursor))
Expand Down

0 comments on commit 2cdae17

Please sign in to comment.