Skip to content
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

Auto completion for dynamic scripts including possible arguments #23

Closed
kaspernissen opened this issue Dec 11, 2018 · 2 comments · Fixed by #37
Closed

Auto completion for dynamic scripts including possible arguments #23

kaspernissen opened this issue Dec 11, 2018 · 2 comments · Fixed by #37
Labels
enhancement New feature or request

Comments

@kaspernissen
Copy link
Member

Auto completion for dynamic scripts and arguments would enhance the experience using shuttle

@Crevil
Copy link
Member

Crevil commented Dec 17, 2018

Cobra support this pretty easily already. The project has some documentation on how to do it based of how kubectl handles completion of pod names etc.

https://github.com/spf13/cobra/blob/master/bash_completions.md

Basically what we need to do is to write some bash script that uses shuttle list or equivalent commands to get available targets.
I'm not completely sure on how to get the argument specifications.

Maybe if we make the list command able to parse the argument descriptions as well we could maybe do a lookup when the command is selected.

Some seudo code for the approach:

shuttle run [tab][tab]                     # lookup targets with 'shuttle list'
shuttle run build [tab][tab]           # lookup flags with 'shuttle list build'

@Crevil Crevil added the enhancement New feature or request label Dec 17, 2018
Crevil added a commit that referenced this issue Dec 20, 2018
First stop to fix #23

Missing completion on arguments but we must modify the ls command to expose this information to make the implementation sane here.
@Crevil
Copy link
Member

Crevil commented Dec 20, 2018

With #14 implemented we can extend it with the option to define a template to shuttle run <script> --help --template -o=go-template.
This way we can query the arguments of each script and control the output.

Crevil added a commit that referenced this issue Dec 20, 2018
Control the output of 'shuttle run test --help' with --template.

$ shuttle run test --help --template '{{.Description}}'
Run shuttle test suite for both Go and bash source code.

Part of solving #23
Crevil added a commit that referenced this issue Apr 6, 2019
First stop to fix #23

Missing completion on arguments but we must modify the ls command to expose this information to make the implementation sane here.
@Crevil Crevil closed this as completed in #37 Apr 9, 2019
Crevil added a commit that referenced this issue Apr 9, 2019
Bash custom completions for the run command.

When cobra fails to find completions for the run command the bash function '__shuttle_custom_func' is called.
The function looks up available scripts to run through shuttle it self (shuttle ls) and available arguments for the chosen script (shuttle run script --help).

zsh completion is handled by wrapping the bash completions. This is copied by the way kubectl handles this.

Closes #23.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants