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

#51 Enable completion command to generate shell completions #60

Merged
merged 7 commits into from
Oct 21, 2024

Conversation

Somsubhra
Copy link
Contributor

@Somsubhra Somsubhra commented Oct 17, 2024

#51 Enable completion command to generate shell completions

Description

This PR enables the completion command in score-k8s to generate shell completions.

Command Description

score-k8s completion
Generate the autocompletion script for score-k8s for the specified shell.
See each sub-command's help for details on how to use the generated script.

Usage:
  score-k8s completion [command]

Available Commands:
  bash        Generate the autocompletion script for bash
  fish        Generate the autocompletion script for fish
  powershell  Generate the autocompletion script for powershell
  zsh         Generate the autocompletion script for zsh

Flags:
  -h, --help   help for completion

Global Flags:
      --quiet           Mute any logging output
  -v, --verbose count   Increase log verbosity and detail by specifying this flag one or more times

Use "score-k8s completion [command] --help" for more information about a command.

Example

➜  ~ score-k8s completion zsh > ~/tmp/score-k8s.zsh.completion
➜  ~ source ~/tmp/score-k8s.zsh.completion
➜  ~ score-k8s
completion  -- Generate the autocompletion script for the specified shell
generate    -- Convert one or more Score files into a set of Kubernetes manifests
help        -- Help about any command
init        -- Initialise a new score-k8s project with local state directory and sample score file
resources   -- Subcommands related to provisioned resources

What does this PR do?

Remove the cobra configuration which hides the completion command

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • New chore (expected functionality to be implemented)

Checklist:

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I've signed off with an email address that matches the commit author.

@mathieu-benoit
Copy link
Contributor

Thanks for your contribution, @Somsubhra, much appreciated.

From a usability/end-user perspective this LGTM, but I would love to get the review from @delca85 or @astromechza on this. For example, in score-compose, we apparently have some unit tests around the completion command: https://github.com/score-spec/score-compose/blob/main/internal/command/root_test.go#L62-L253, do we want this here too?

@Somsubhra
Copy link
Contributor Author

Makes sense, I will add tests.

@Somsubhra
Copy link
Contributor Author

Done - tests are added and they are passing in CI.

@mathieu-benoit mathieu-benoit self-requested a review October 19, 2024 15:31
Copy link
Contributor

@mathieu-benoit mathieu-benoit left a comment

Choose a reason for hiding this comment

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

Thanks @Somsubhra!

LGTM

Let's have a second pair of eyes on this, thanks for your review @delca85 in case we are missing anything here?

Copy link

@delca85 delca85 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@mathieu-benoit mathieu-benoit merged commit 50f6bd1 into score-spec:main Oct 21, 2024
4 checks passed
@mathieu-benoit mathieu-benoit linked an issue Oct 21, 2024 that may be closed by this pull request
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.

[feature request] completion subcommand
3 participants