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

Include flag descriptions when using zsh completion #1903

Merged
merged 2 commits into from
May 2, 2024

Conversation

Toalaah
Copy link
Contributor

@Toalaah Toalaah commented May 1, 2024

What type of PR is this?

  • feature

What this PR does / why we need it:

This PR ensures that flags' Usage fields are included when using zsh completion (if their description is non-empty). This functionality is in line with how this is handled for command completion, see

cli/help.go

Line 163 in 043b774

_, _ = fmt.Fprintf(writer, "%s:%s\n", command.Name, command.Usage)

Without Changes

without-desc

With changes

with-desc

Testing

I tested these changes locally against a CLI tool that I am migrating to urfave/cli/v3. I also ran make test and encountered no errors, but then again I also did not add any test cases (would be open to doing so if this feature is desired).

Release Notes

Flag usage fields are now included when using zsh completion

@Toalaah Toalaah requested a review from a team as a code owner May 1, 2024 16:41
@bartekpacia
Copy link
Member

Hi @Toalaah! Thank you very much for the contribution :)

Copy link
Member

@bartekpacia bartekpacia left a comment

Choose a reason for hiding this comment

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

LGTM.

@bartekpacia
Copy link
Member

@meatballhat @Juneezee What should be done when codecov fails, like in this PR?

@Juneezee
Copy link
Member

Juneezee commented May 2, 2024

@meatballhat @Juneezee What should be done when codecov fails, like in this PR?

@bartekpacia I think the simplest way would be adding a test case for zsh in TestDefaultCompleteWithFlags

cli/help_test.go

Lines 1079 to 1083 in 043b774

func TestDefaultCompleteWithFlags(t *testing.T) {
origArgv := os.Args
t.Cleanup(func() { os.Args = origArgv })
t.Setenv("SHELL", "bash")

@Toalaah
Copy link
Contributor Author

Toalaah commented May 2, 2024

Thanks for the hint, added some zsh-specific test cases. Looks like codecov is no longer complaining.

@bartekpacia
Copy link
Member

Thanks a lot :-)

@bartekpacia bartekpacia merged commit c44118c into urfave:main May 2, 2024
13 checks passed
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.

3 participants