Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Add autocomplete for bash and zsh in lokoctl #880

Merged
merged 1 commit into from Sep 1, 2020

Conversation

knrt10
Copy link
Member

@knrt10 knrt10 commented Aug 28, 2020

Fixes #18

Signed-off-by: knrt10 kautilya@kinvolk.io

@knrt10 knrt10 force-pushed the knrt10/add-autocompletion branch 6 times, most recently from b51fea4 to b661405 Compare August 28, 2020 13:41
cli/cmd/completion.go Outdated Show resolved Hide resolved
docs/cli/lokoctl_completion_zsh.md Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
@knrt10
Copy link
Member Author

knrt10 commented Aug 29, 2020

@invidian, so I think, we should currently go for this until cobra releases it's new updates. Do you agree?

@knrt10
Copy link
Member Author

knrt10 commented Aug 29, 2020

For 0.4 we can release it with this, if by 0.5 cobra releases their new updates, we can change it to GenZshCompletion

@invidian
Copy link
Member

For 0.4 we can release it with this, if by 0.5 cobra releases their new updates, we can change it to GenZshCompletion

Or we could do bash completion for 0.4 and zsh completion for the next release? What do you think @johananl? Or we could postpone this completely.

@knrt10
Copy link
Member Author

knrt10 commented Aug 31, 2020

As mentioned in #880 (comment) we don't know when the next cobra release will be, but if we do want to use GenZshCompletion one alternative is to use, ValidArgs instead of ValidArgsFunction and provide arguments explicitly for both cluster apply and delete.

Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

Some nits, otherwise LGTM 👍

cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
@knrt10 knrt10 requested a review from invidian August 31, 2020 10:20
@knrt10 knrt10 force-pushed the knrt10/add-autocompletion branch 2 times, most recently from b4c5ebf to b016146 Compare August 31, 2020 10:22
docs/cli/lokoctl.md Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
@knrt10
Copy link
Member Author

knrt10 commented Aug 31, 2020

@johananl could you please review again?

@knrt10 knrt10 force-pushed the knrt10/add-autocompletion branch 2 times, most recently from 1b81139 to dba8989 Compare August 31, 2020 11:59
BrainBlasted
BrainBlasted previously approved these changes Aug 31, 2020
@knrt10 knrt10 dismissed invidian’s stale review August 31, 2020 14:04

requested again

Copy link
Member

@johananl johananl left a comment

Choose a reason for hiding this comment

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

Thanks @knrt10.

I'm still seeing small inconsistencies. I've highlighted some of them inline. We also seem to be using multiple variations of "completion/autocompletion" and "script/code". Let's settle on one phrasing 😉

cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
# Set the lokoctl completion code for zsh to autoload on startup.
lokoctl completion zsh > "${fpath[1]}/_lokoctl" && exec $SHELL`

const bashCompDesc = ` ### If running Bash 3.2 that is included with macOS, install bash completion using homebrew.
Copy link
Member

Choose a reason for hiding this comment

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

Why use ###? Is this some sort of convention?

Copy link
Member Author

@knrt10 knrt10 Aug 31, 2020

Choose a reason for hiding this comment

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

For docs, otherwise, they look wierd, because single # is considered as Header 1

cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
cli/cmd/completion.go Outdated Show resolved Hide resolved
@knrt10
Copy link
Member Author

knrt10 commented Aug 31, 2020

Updated

@knrt10 knrt10 requested a review from johananl August 31, 2020 14:40
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

Just one nit, otherwise looks fine to me.

cli/cmd/completion.go Outdated Show resolved Hide resolved
invidian
invidian previously approved these changes Aug 31, 2020
Copy link
Contributor

@iaguis iaguis left a comment

Choose a reason for hiding this comment

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

Some small comments.

cli/cmd/completion.go Show resolved Hide resolved
cli/cmd/completion.go Show resolved Hide resolved
cli/cmd/completion.go Show resolved Hide resolved
Fixes #18

Signed-off-by: knrt10 <kautilya@kinvolk.io>
Copy link
Contributor

@iaguis iaguis left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

LGTM

@knrt10
Copy link
Member Author

knrt10 commented Sep 1, 2020

tested for both zsh and bash. Merging now. Thanks, everyone for the review

@knrt10 knrt10 merged commit 375f2c4 into master Sep 1, 2020
@knrt10 knrt10 deleted the knrt10/add-autocompletion branch September 1, 2020 10:25
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.

Add Bash/zsh autocompletion
6 participants