urfave / cli

A simple, fast, and fun package for building command line apps in Go
https://cli.urfave.org
MIT License
21.89k stars 1.69k forks source link

Include flag descriptions when using zsh completion #1903

Closed Toalaah closed 1 month ago

Toalaah commented 1 month ago

What type of PR is this?

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 https://github.com/urfave/cli/blob/043b774d0f2c64d2ed4e22e87c2f6ec54bfcb30b/help.go#L163

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
bartekpacia commented 1 month ago

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

bartekpacia commented 1 month ago

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

Juneezee commented 1 month ago

@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

https://github.com/urfave/cli/blob/043b774d0f2c64d2ed4e22e87c2f6ec54bfcb30b/help_test.go#L1079-L1083

Toalaah commented 1 month ago

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

bartekpacia commented 1 month ago

Thanks a lot :-)