-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
flag for -h does not work after set HelpFlag to something else #546
Comments
Hi @robin11, With package main
import (
"os"
"github.com/urfave/cli"
)
func main() {
cli.HelpFlag = cli.BoolFlag{
Name: "help",
Usage: "To show help for the tool",
}
cli.NewApp().Run(os.Args)
} You should see:
As you can see, the help message does print, but that is because it considers the passed flag, You can override this behavior by setting
Which will show:
Let me know if this helps! |
thanks for your help!I have already see the situation you post,but this is not what i want.Below is the sample code I use.In the comand ls,I have a "-h " flag,but it does not work!
|
Aha, I see what you are saying now. This actually appears to be because of special handling of I unfortunately don't see an easy workaround without replacing the parser or vendoring it and patching, but this is definitely a bug. I'd lean towards the latter in the short term. |
I am facing the same problem. |
I checked the source code. I found the key problem is at command.go line 173. Function func checkCommandHelp(c *Context, name string) bool {
if c.Bool("h") || c.Bool("help") {
ShowCommandHelp(c, name)
return true
}
return false
} Every command run will call this function, and check flag The solution can be removing |
@asahasrabuddhe I'm un-assigning this since there's hasn't been any movement on it recently! @ everyone else, please feel free to help with this 🙏 |
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. |
This definitely seems like something we should consider fixing 👍 we're still waiting on someone who wants to contribute, though! 🙏 |
This issue or PR has been bumped and is no longer marked as stale! Feel free to bump it again in the future, if it's still relevant. |
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. |
Closing this as it has become stale. |
Wont fix in v1, v2 as it requires a rewrite of stdlib flag parser |
Hello! I need the "-h" flag for my command ,so I set the HelpFlag to "help",without "h".But it turned out that "-h" still show for help which is not I want!
First I set helpFLag to "help"
Then in my command "ls", I have a flag "h",but it still shows for help.Hope someone would help!
The text was updated successfully, but these errors were encountered: