Skip to content

Fix zsh completion #806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2020
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
4 changes: 2 additions & 2 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
9 changes: 1 addition & 8 deletions cli/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down