From aabd31db81c58c4f945b5214509ece61226d203f Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Wed, 10 Apr 2024 08:55:38 -0500 Subject: [PATCH] fix: shell-completion --- README.md | 1 - cmd/{shell-completion.go => completion.go} | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) rename cmd/{shell-completion.go => completion.go} (74%) diff --git a/README.md b/README.md index 7a860fbc..f6257699 100644 --- a/README.md +++ b/README.md @@ -349,7 +349,6 @@ Available Commands: eval (default) Apply the expression to each document in each yaml file in sequence eval-all Loads _all_ yaml documents of _all_ yaml files and runs expression once help Help about any command - shell-completion Generate completion script Flags: -C, --colors force print with colors diff --git a/cmd/shell-completion.go b/cmd/completion.go similarity index 74% rename from cmd/shell-completion.go rename to cmd/completion.go index ea031f89..aae72a62 100644 --- a/cmd/shell-completion.go +++ b/cmd/completion.go @@ -7,19 +7,20 @@ import ( ) var completionCmd = &cobra.Command{ - Use: "shell-completion [bash|zsh|fish|powershell]", - Short: "Generate completion script", + Use: "completion [bash|zsh|fish|powershell]", + Aliases: []string{"shell-completion"}, + Short: "Generate shell completion script", Long: `To load completions: Bash: -$ source <(yq shell-completion bash) +$ source <(yq completion bash) # To load completions for each session, execute once: Linux: - $ yq shell-completion bash > /etc/bash_completion.d/yq + $ yq completion bash > /etc/bash_completion.d/yq MacOS: - $ yq shell-completion bash > /usr/local/etc/bash_completion.d/yq + $ yq completion bash > /usr/local/etc/bash_completion.d/yq Zsh: @@ -29,16 +30,16 @@ Zsh: $ echo "autoload -U compinit; compinit" >> ~/.zshrc # To load completions for each session, execute once: -$ yq shell-completion zsh > "${fpath[1]}/_yq" +$ yq completion zsh > "${fpath[1]}/_yq" # You will need to start a new shell for this setup to take effect. Fish: -$ yq shell-completion fish | source +$ yq completion fish | source # To load completions for each session, execute once: -$ yq shell-completion fish > ~/.config/fish/completions/yq.fish +$ yq completion fish > ~/.config/fish/completions/yq.fish `, DisableFlagsInUseLine: true, ValidArgs: []string{"bash", "zsh", "fish", "powershell"},