Skip to content

Commit b2ed18f

Browse files
authored
Fix zsh completion (#806)
* revert hack: it was breaking flag description * square brackets did not got escaped correctly in the completion script
1 parent b148c00 commit b2ed18f

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

Diff for: cli/cli.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ func createCliCommandTree(cmd *cobra.Command) {
9696
viper.BindPFlag("logging.level", cmd.PersistentFlags().Lookup("log-level"))
9797
cmd.PersistentFlags().String("log-file", "", "Path to the file where logs will be written.")
9898
viper.BindPFlag("logging.file", cmd.PersistentFlags().Lookup("log-file"))
99-
cmd.PersistentFlags().String("log-format", "", "The output format for the logs, can be [text|json].")
99+
cmd.PersistentFlags().String("log-format", "", "The output format for the logs, can be {text|json}.")
100100
viper.BindPFlag("logging.format", cmd.PersistentFlags().Lookup("log-format"))
101-
cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", "The output format, can be [text|json].")
101+
cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", "The output format, can be {text|json}.")
102102
cmd.PersistentFlags().StringVar(&configFile, "config-file", "", "The custom config file (if not specified the default will be used).")
103103
cmd.PersistentFlags().StringSlice("additional-urls", []string{}, "Additional URLs for the board manager.")
104104
viper.BindPFlag("board_manager.additional_urls", cmd.PersistentFlags().Lookup("additional-urls"))

Diff for: cli/completion/completion.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,7 @@ func run(cmd *cobra.Command, args []string) {
5656
cmd.Root().GenBashCompletion(os.Stdout)
5757
break
5858
case "zsh":
59-
buf := new(bytes.Buffer)
60-
cmd.Root().GenZshCompletion(buf)
61-
// Next 3 lines are Hack, we'll wait new version of cobra with ZshV2Completion https://github.com/spf13/cobra/pull/1070
62-
//insert escaping before [ and ]
63-
s := strings.ReplaceAll(buf.String(), "[", "\\[")
64-
s = strings.ReplaceAll(s, "]", "\\]")
65-
s = strings.ReplaceAll(s, "\\[1\\]", "[1]") // revert the case
66-
os.Stdout.WriteString(s)
59+
cmd.Root().GenZshCompletion(os.Stdout)
6760
break
6861
case "fish":
6962
buf := new(bytes.Buffer)

0 commit comments

Comments
 (0)