From 23da5f6194c18008f1af6c2266cd5570a572f299 Mon Sep 17 00:00:00 2001 From: umbynos Date: Thu, 9 Jul 2020 10:24:46 +0200 Subject: [PATCH 1/2] revert hack: it was breaking flag description --- cli/completion/completion.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cli/completion/completion.go b/cli/completion/completion.go index ffe5472728e..c5412baadbc 100644 --- a/cli/completion/completion.go +++ b/cli/completion/completion.go @@ -56,14 +56,7 @@ func run(cmd *cobra.Command, args []string) { cmd.Root().GenBashCompletion(os.Stdout) break case "zsh": - buf := new(bytes.Buffer) - cmd.Root().GenZshCompletion(buf) - // Next 3 lines are Hack, we'll wait new version of cobra with ZshV2Completion https://github.com/spf13/cobra/pull/1070 - //insert escaping before [ and ] - s := strings.ReplaceAll(buf.String(), "[", "\\[") - s = strings.ReplaceAll(s, "]", "\\]") - s = strings.ReplaceAll(s, "\\[1\\]", "[1]") // revert the case - os.Stdout.WriteString(s) + cmd.Root().GenZshCompletion(os.Stdout) break case "fish": buf := new(bytes.Buffer) From 97f1affe7d6713166332fe36e9eea735b230b1fb Mon Sep 17 00:00:00 2001 From: umbynos Date: Thu, 9 Jul 2020 10:25:30 +0200 Subject: [PATCH 2/2] square brackets did not got escaped correctly in the completion script --- cli/cli.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index deee144da45..a29faa25a08 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -96,9 +96,9 @@ func createCliCommandTree(cmd *cobra.Command) { viper.BindPFlag("logging.level", cmd.PersistentFlags().Lookup("log-level")) cmd.PersistentFlags().String("log-file", "", "Path to the file where logs will be written.") viper.BindPFlag("logging.file", cmd.PersistentFlags().Lookup("log-file")) - cmd.PersistentFlags().String("log-format", "", "The output format for the logs, can be [text|json].") + cmd.PersistentFlags().String("log-format", "", "The output format for the logs, can be {text|json}.") viper.BindPFlag("logging.format", cmd.PersistentFlags().Lookup("log-format")) - cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", "The output format, can be [text|json].") + cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", "The output format, can be {text|json}.") cmd.PersistentFlags().StringVar(&configFile, "config-file", "", "The custom config file (if not specified the default will be used).") cmd.PersistentFlags().StringSlice("additional-urls", []string{}, "Additional URLs for the board manager.") viper.BindPFlag("board_manager.additional_urls", cmd.PersistentFlags().Lookup("additional-urls"))