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

Bash and zsh auto completions #37

Merged
merged 12 commits into from Apr 9, 2019
Merged

Bash and zsh auto completions #37

merged 12 commits into from Apr 9, 2019

Conversation

Crevil
Copy link
Member

@Crevil Crevil commented Apr 6, 2019

This PR adds auto-completion to run scripts.

This is an example of the outputs in zsh.

$ shuttle run --[tab]
--clean      --plan       --project    --skip-pull  --template   --verbose
$ shuttle run [tab] 
release     test        test-go     test-shell
$ shuttle run t[tab]
$ shuttle run test
$ shuttle run test[tab]
test        test-go     test-shell

It works for script arguments as well.

scripts:
  test:
    args:
    - name: tag
    - name: version
$ shuttle run test [tab]
tag      version

Changes

  • Custom completion function to the root command that will be called when ever the generated cobra completions don't have an answer.
    This is the case when calling the run command as we don't know at compile time what scripts will be available.

  • template flag added to the ls command to allow for simple programatic lookups of scripts.

  • cobra upgraded to commit spf13/cobra@d2d81d9 as there is a bug in the custome completion implementation (Fix too many underscore for __custom_func spf13/cobra#794). The bug is fixed but not released.

Closes #23

@Crevil Crevil marked this pull request as ready for review April 6, 2019 21:12
@kaspernissen
Copy link
Member

This is awesome! 👏 Great job, @Crevil !
Not sure, if I'm the best to review this PR, but from what I can see, it looks good!

@Crevil Crevil removed the request for review from emilingerslev April 9, 2019 18:22
@Crevil Crevil merged commit b868e70 into master Apr 9, 2019
@Crevil Crevil deleted the feature/completions branch April 9, 2019 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto completion for dynamic scripts including possible arguments
2 participants