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

can I remove default text when a flag's value is set #1277

Closed
seyoatda opened this issue May 27, 2021 · 15 comments
Closed

can I remove default text when a flag's value is set #1277

seyoatda opened this issue May 27, 2021 · 15 comments
Assignees
Labels
area/v2 relates to / is being considered for v2 kind/question someone asking a question status/claimed someone has claimed this issue status/waiting-for-response Waiting for response from original requester
Milestone

Comments

@seyoatda
Copy link

No description provided.

@seyoatda seyoatda changed the title can I remove default text when a flag "Value" is set can I remove default text when a flag's value is set May 27, 2021
@seyoatda
Copy link
Author

It seems that when I set a flag's value, the help info will show a default text , even if I do not try to set a default text hint.
for example, if I create a IntFlag, then its value is 0 as default, which is initialize by golang itself. then the default text is shown as (default: 0). But I didn't set the value as 0, and the default text was not supposed to show

@stale
Copy link

stale bot commented Aug 25, 2021

This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.

@stale stale bot added the status/stale stale due to the age of it's last update label Aug 25, 2021
@Toady00
Copy link

Toady00 commented Oct 14, 2021

I have a similar issue I'm not sure how to handle. If I set an env var for a flag, say for a sensitive value like an api token, I don't want the help outputing that token as a "default" value if it's set in the environment at the time. How do I use the EnvVars flags without effecting the default help text?

@valorl
Copy link

valorl commented Nov 1, 2021

@Toady00 One thing I found you can do is set DefaultText: "" on the flag.

@meatballhat meatballhat added kind/question someone asking a question area/v2 relates to / is being considered for v2 and removed status/stale stale due to the age of it's last update labels Apr 21, 2022
@lorensr
Copy link

lorensr commented Sep 23, 2022

@valorl's suggestion isn't working for me with a BoolFlag:

--help, -h                       Show help (default: false)

image

@dearchap dearchap added the status/claimed someone has claimed this issue label Oct 18, 2022
@dearchap dearchap self-assigned this Oct 18, 2022
@dearchap
Copy link
Contributor

@lorensr Can you check if this problem exists with latest release as well ? We've made some changes to default handling

@dearchap dearchap added the status/waiting-for-response Waiting for response from original requester label Oct 19, 2022
@lorensr
Copy link

lorensr commented Dec 28, 2022

@dearchap I'm getting the same behavior on latest v2.23.7

@dearchap dearchap reopened this Dec 28, 2022
@dearchap
Copy link
Contributor

@lorensr can you post a code snippet ?

@lorensr
Copy link

lorensr commented Dec 28, 2022

cli.HelpFlag = &cli.BoolFlag{
	Name:    "help",
	Aliases: []string{"h"},
	Usage:   "Show help",
	DefaultText: "",
}

Setting DefaultText: "" does not remove the (default: false) output below:

--help, -h                       Show help (default: false)

Diff: temporalio/cli@main...repro-1277
Repro: https://github.com/temporalio/cli/tree/repro-1277

@dearchap
Copy link
Contributor

Can you set DefaultText to " " or a non empty string?

@lorensr
Copy link

lorensr commented Dec 29, 2022

Here is " ":

   --help, -h     Show help (default:  )

@dearchap
Copy link
Contributor

Okay I see the issue now. So would you like to hide the default text only for bool flags or for all flags ?

@lorensr
Copy link

lorensr commented Dec 29, 2022

Only for these two flags:

GLOBAL OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)

and not for other bool flags or flags of other types.

@dearchap
Copy link
Contributor

@lorensr Can you try the PR and see if it works for you ? Thanks

@dearchap dearchap closed this as completed Jan 6, 2023
@lorensr
Copy link

lorensr commented Aug 3, 2023

@dearchap I'm on v2.25.7, and now by default I don't see (default: false). However, if I change show help to Show help with this, (default: false) comes back:

cli.HelpFlag = &cli.BoolFlag{
	Name:    "help",
	Aliases: []string{"h"},
	Usage:   "Show help",
	DefaultText: "",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2 kind/question someone asking a question status/claimed someone has claimed this issue status/waiting-for-response Waiting for response from original requester
Projects
None yet
Development

No branches or pull requests

6 participants