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

Add env variable to suppress completion descriptions on create #1938

Merged
merged 7 commits into from
Dec 17, 2023

Conversation

scop
Copy link
Contributor

@scop scop commented Mar 27, 2023

Closes #1937

@marckhouzam
Copy link
Collaborator

Thanks @scop !
This approach will only work for programs that use the default completion command. Also it would require regenerating the completion script to toggle the descriptions.

Instead we could have the go code itself check the new variable and not return descriptions with the list of completions.

This is what we do for activehelp and probably what I should have done for descriptions from the start.

This go logic would be here:

noDescriptions := (cmd.CalledAs() == ShellCompNoDescRequestCmd)

@Luap99
Copy link
Contributor

Luap99 commented Mar 28, 2023

I agree we should follow what active helps does , this includes support for two env vars, i.e. COBRA_COMPLETION_NO_DESCRIPTIONS and <PROGRAM>_COMPLETION_NO_DESCRIPTIONS, this allows users to still configure it on a per application basis without having to regenerate the completion script.

@marckhouzam
Copy link
Collaborator

Thanks for the input @Luap99 👍

COBRA_COMPLETION_NO_DESCRIPTIONS and _COMPLETION_NO_DESCRIPTIONS

Let's "go" 😆 with this flexible and"standard" approach if @scop is willing.

@scop
Copy link
Contributor Author

scop commented Mar 28, 2023

Makes sense. I suggest we take a look at #1940 before reworking this though -- if/after that's in, the env var prefix handling could be generalized and shared between active help and this feature.

@scop scop marked this pull request as draft March 28, 2023 18:20
@scop scop force-pushed the feat/disable-descriptions-envvar branch 3 times, most recently from 4474cf6 to 2c46d19 Compare October 24, 2023 21:06
@scop
Copy link
Contributor Author

scop commented Oct 24, 2023

I suppose this is starting to take shape, however it requires #1940, so keeping as a draft until that's in.

This will also cause conflicts with #1957, so either this or that will eventually need rebasing. This one's still blocked and #1957 is not, so perhaps that one could be applied first? Then again, I would not want to delay this one any more.

@scop scop force-pushed the feat/disable-descriptions-envvar branch from 2c46d19 to 5c206d1 Compare October 29, 2023 20:02
@scop scop marked this pull request as ready for review October 29, 2023 20:02
@github-actions
Copy link

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@scop scop force-pushed the feat/disable-descriptions-envvar branch from 5c206d1 to 97b7001 Compare November 26, 2023 14:50
@scop
Copy link
Contributor Author

scop commented Nov 26, 2023

Resolved conflicts, rebased.

Copy link
Collaborator

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

Thanks for your patience @scop

completions.go Outdated Show resolved Hide resolved
completions.go Outdated Show resolved Hide resolved
completions.go Show resolved Hide resolved
completions.go Outdated Show resolved Hide resolved
completions_test.go Outdated Show resolved Hide resolved
completions_test.go Outdated Show resolved Hide resolved
@scop scop force-pushed the feat/disable-descriptions-envvar branch from 00019d5 to c96f1a6 Compare December 11, 2023 16:11
@scop scop force-pushed the feat/disable-descriptions-envvar branch from 977823c to 1107319 Compare December 11, 2023 20:19
Copy link

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@scop
Copy link
Contributor Author

scop commented Dec 11, 2023

Thanks for the review, @marckhouzam, feedback addressed.

Copy link
Collaborator

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

Very nice!
Thanks @scop.

@marckhouzam marckhouzam merged commit e63925d into spf13:main Dec 17, 2023
16 checks passed
@marckhouzam marckhouzam added this to the 1.9.0 milestone Dec 17, 2023
@marckhouzam marckhouzam added kind/feature A feature request for cobra; new or enhanced behavior area/shell-completion All shell completions labels Dec 17, 2023
@scop scop deleted the feat/disable-descriptions-envvar branch December 19, 2023 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/shell-completion All shell completions kind/feature A feature request for cobra; new or enhanced behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFE: env var for disabling descriptions
3 participants