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

[sparo] shell completion feature #83

Merged
merged 7 commits into from
Aug 15, 2024
Merged

[sparo] shell completion feature #83

merged 7 commits into from
Aug 15, 2024

Conversation

chengcyber
Copy link
Member

@chengcyber chengcyber commented Aug 8, 2024

Basic Checks

Have you run rush change for this change?

  • Yes
  • No

If No, please run rush change before, this is necessary.

If adding a new feature, the PR's description includes:

  • Reason for adding this feature
  • How to use
  • A basic example

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

Summary

This PR adds completion feature to Sparo CLI

Detail

Shell completion can improve the user experience when running Sparo commands. This PR leverages yargs's completion feature to support completion for most all commands.

  1. To enable completion:

User needs to add eval "$(sparo completion)" to ~/.zshrc file. The "sparo completion" command prints shell script and loaded by the eval command.

Remember to use source ~/.zshrc to make it take effect immediately.

  1. To use completion:

I would like to put some show cases here. Just type in the terminal and press "Tab" to trigger completion.

a. Top level sparo command completion
CleanShot 2024-08-08 at 15 03 55@2x

b. sparo add file completion
CleanShot 2024-08-08 at 15 06 07@2x

c. sparo checkout --profile completion
CleanShot 2024-08-08 at 15 06 38@2x

d. sparo checkout --to completion
CleanShot 2024-08-08 at 15 07 08@2x

e. sparo list-profiles --project completion
CleanShot 2024-08-08 at 15 08 32@2x

How to test it

  1. Added a build test in this PR for testing the entire completion feature

  2. Run the following command to test completion locally:

/path/to/local/sparo --get-yargs-completions sparo <command> ...

@chengcyber chengcyber force-pushed the feat-sparo-completion branch from cdabc85 to 6f992e7 Compare August 9, 2024 00:01
@chengcyber chengcyber force-pushed the feat-sparo-completion branch from ee1cc12 to eb56f66 Compare August 12, 2024 20:47
@chengcyber chengcyber force-pushed the feat-sparo-completion branch from eb56f66 to 427acc5 Compare August 12, 2024 23:40
@jzhang026 jzhang026 enabled auto-merge August 15, 2024 14:30
@jzhang026 jzhang026 merged commit 30a6efe into main Aug 15, 2024
3 checks passed
@jzhang026 jzhang026 deleted the feat-sparo-completion branch August 15, 2024 14:30
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.

2 participants