Repository navigation
Bash completion - #166
Bash completion#166
Conversation
Completion now supports both the --param value and the --param=value formats when forwarding flags to corectl lookup calls Moved engine,app,ttl,headers,config flags to top most command level to work better with the autocomplete feature
|
|
||
| `corectl` provides auto completion of commands and flags for `bash` and `zsh`. To load completion in your shell add the following to your `~/.bashrc` or `~/.zshrc` file depending on shell. | ||
|
|
||
| `. <(corectl completion bash)` or `. <(corectl completion zsh)` |
There was a problem hiding this comment.
Don't you need source infront of the command? or maybe the . is the same???
There was a problem hiding this comment.
Yep, works with both source and .
There was a problem hiding this comment.
Can we have a bit more details here? I think it might be hard for people to understand if they're not well-versed in terminal lingo.
I'm thinking instructions per platform similar to https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion
|
|
||
| `. <(corectl completion bash)` or `. <(corectl completion zsh)` | ||
|
|
||
| Auto completion requires `jq` and `bash-completion` to be installed. |
There was a problem hiding this comment.
Can we have install instructions for these? I don't think jq is very common, is there any way we can avoid that dependency?
There was a problem hiding this comment.
Also, perhaps move this above the source commands, feels weird to list the dependencies after they started installing the script
| command.PersistentFlags().StringToStringVar(&headersMap, "headers", nil, "Headers to use when connecting to qix engine") | ||
| } | ||
| //not binding to viper since binding a map does not seem to work. | ||
| rootCmd.PersistentFlags().StringToStringVar(&headersMap, "headers", nil, "Headers to use when connecting to qix engine") |
There was a problem hiding this comment.
Maybe add HTTP >> "HTTP headers ..."
| // completionCmd generates auto completion commands | ||
| var completionCmd = &cobra.Command{ | ||
| Use: "completion <shell>", | ||
| Hidden: true, |
There was a problem hiding this comment.
I guess it depends on if we want it visible in the help or not. IMO it's enough to document it in the README and keep it as hidden.
There was a problem hiding this comment.
If it's a "public" API I think it should be visible
|
|
||
| `corectl` provides auto completion of commands and flags for `bash` and `zsh`. To load completion in your shell add the following to your `~/.bashrc` or `~/.zshrc` file depending on shell. | ||
|
|
||
| `. <(corectl completion bash)` or `. <(corectl completion zsh)` |
There was a problem hiding this comment.
Can we have a bit more details here? I think it might be hard for people to understand if they're not well-versed in terminal lingo.
I'm thinking instructions per platform similar to https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion
|
|
||
| `. <(corectl completion bash)` or `. <(corectl completion zsh)` | ||
|
|
||
| Auto completion requires `jq` and `bash-completion` to be installed. |
There was a problem hiding this comment.
Can we have install instructions for these? I don't think jq is very common, is there any way we can avoid that dependency?
|
|
||
| `. <(corectl completion bash)` or `. <(corectl completion zsh)` | ||
|
|
||
| Auto completion requires `jq` and `bash-completion` to be installed. |
There was a problem hiding this comment.
Also, perhaps move this above the source commands, feels weird to list the dependencies after they started installing the script
| Hidden: true, | ||
| Use: "corectl", | ||
| Short: "", | ||
| Long: `Corectl contains various commands to interact with the Qlik Associative Engine. See respective command for more information`, |
| command.PersistentFlags().StringToStringVar(&headersMap, "headers", nil, "Headers to use when connecting to qix engine") | ||
| } | ||
| //not binding to viper since binding a map does not seem to work. | ||
| rootCmd.PersistentFlags().StringToStringVar(&headersMap, "headers", nil, "Headers to use when connecting to qix engine") |
| ValidArgs: []string{"zsh", "bash"}, | ||
| Args: cobra.MinimumNArgs(1), | ||
| Short: "Generates auto completion scripts", | ||
| Long: `To load completion add the following to your ~/.bashrc or ~/.zshrc file |
There was a problem hiding this comment.
Can we detect the shell and output the info for their current shell maybe?
| Short: "Generates auto completion scripts", | ||
| Long: `To load completion add the following to your ~/.bashrc or ~/.zshrc file | ||
|
|
||
| . <(corectl completion zsh) |
There was a problem hiding this comment.
This requires corectl to be in PATH, right? Do we need a note on that in README as a requirement?
|
|
||
| . <(corectl completion bash) | ||
|
|
||
| If you are running on OSX you will also need to install bash-completion e.g through brew. |
There was a problem hiding this comment.
Redundant information, I understand that we want this to be accessible but it's easy to miss one place if we need to update the info, perhaps link to a section in README?
| } | ||
|
|
||
| // Code for generating zsh bash completion script | ||
| // Inspired by https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/completion/completion.go |
There was a problem hiding this comment.
I think we should have this similar to how we did in core-scaling: https://github.com/qlik-oss/core-scaling/blob/master/LICENSE
| @@ -13,9 +13,14 @@ corectl [flags] | |||
| ### Options | |||
There was a problem hiding this comment.
It says options here, but corectl [flags] in the instruction above, normalize?
|
I will merge this PR since we have other tasks pending on this. Lets handle any outstanding issues as separate tasks. |
Bash (and Zsh) completion for corectl including lookup of available apps, connections, objects, dimensions and measures