Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.

Bash completion - #166

Merged
wennmo merged 11 commits into
masterfrom
bash-completion
Mar 22, 2019
Merged

wennmo merged 11 commits into
masterfrom
bash-completion

Conversation

@gabbaxx

@gabbaxx gabbaxx commented Mar 20, 2019

Copy link
Copy Markdown
Contributor

Bash (and Zsh) completion for corectl including lookup of available apps, connections, objects, dimensions and measures

wennmo and others added 7 commits March 15, 2019 10:03
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
@wennmo
wennmo requested review from axelssonHakan and peol March 20, 2019 15:42
Comment thread README.md

`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)`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need source infront of the command? or maybe the . is the same???

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, works with both source and .

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread README.md

`. <(corectl completion bash)` or `. <(corectl completion zsh)`

Auto completion requires `jq` and `bash-completion` to be installed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to jq?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have install instructions for these? I don't think jq is very common, is there any way we can avoid that dependency?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, perhaps move this above the source commands, feels weird to list the dependencies after they started installing the script

Comment thread cmd/root.go Outdated
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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add HTTP >> "HTTP headers ..."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qlik Associative Engine

Comment thread cmd/utils.go Outdated
// completionCmd generates auto completion commands
var completionCmd = &cobra.Command{
Use: "completion <shell>",
Hidden: true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hidden?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a "public" API I think it should be visible

@axelssonHakan axelssonHakan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎁

@peol peol left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM. Got a few minor comments.

Comment thread README.md

`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)`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread README.md

`. <(corectl completion bash)` or `. <(corectl completion zsh)`

Auto completion requires `jq` and `bash-completion` to be installed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have install instructions for these? I don't think jq is very common, is there any way we can avoid that dependency?

Comment thread README.md

`. <(corectl completion bash)` or `. <(corectl completion zsh)`

Auto completion requires `jq` and `bash-completion` to be installed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, perhaps move this above the source commands, feels weird to list the dependencies after they started installing the script

Comment thread cmd/root.go Outdated
Hidden: true,
Use: "corectl",
Short: "",
Long: `Corectl contains various commands to interact with the Qlik Associative Engine. See respective command for more information`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't corectl lowercase?

Comment thread cmd/root.go Outdated
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")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qlik Associative Engine

Comment thread cmd/utils.go Outdated
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we detect the shell and output the info for their current shell maybe?

Comment thread cmd/utils.go Outdated
Short: "Generates auto completion scripts",
Long: `To load completion add the following to your ~/.bashrc or ~/.zshrc file

. <(corectl completion zsh)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires corectl to be in PATH, right? Do we need a note on that in README as a requirement?

Comment thread cmd/utils.go Outdated

. <(corectl completion bash)

If you are running on OSX you will also need to install bash-completion e.g through brew.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread cmd/utils.go Outdated
}

// Code for generating zsh bash completion script
// Inspired by https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/completion/completion.go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have this similar to how we did in core-scaling: https://github.com/qlik-oss/core-scaling/blob/master/LICENSE

Comment thread docs/corectl.md
@@ -13,9 +13,14 @@ corectl [flags]
### Options

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says options here, but corectl [flags] in the instruction above, normalize?

@wennmo wennmo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@wennmo

wennmo commented Mar 22, 2019

Copy link
Copy Markdown
Member

I will merge this PR since we have other tasks pending on this. Lets handle any outstanding issues as separate tasks.

@wennmo
wennmo merged commit 0cf4d88 into master Mar 22, 2019
@wennmo
wennmo deleted the bash-completion branch March 22, 2019 07:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

⌂ 换网址