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

Set HelpFlag=nil causes panic #1794

Closed
3 tasks done
wxiaoguang opened this issue Jul 18, 2023 · 0 comments · Fixed by #1796
Closed
3 tasks done

Set HelpFlag=nil causes panic #1794

wxiaoguang opened this issue Jul 18, 2023 · 0 comments · Fixed by #1796
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this

Comments

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jul 18, 2023

My urfave/cli version is

2.25.7

Checklist

  • Are you running the latest v2 release? The list of releases is here.
  • Did you check the manual for your release? The v2 manual is here
  • Did you perform a search about this problem? Here's the GitHub guide about searching.

Describe the bug

The comment says:

// HelpFlag prints the help for all commands and subcommands.
// Set to nil to disable the flag.  The subcommand
// will still be added unless HideHelp or HideHelpCommand is set to true.
var HelpFlag Flag = &BoolFlag{

But the code:

func checkHelp(cCtx *Context) bool {
	found := false
	for _, name := range HelpFlag.Names() {  // !!!!!!!!!  PANIC here
		if cCtx.Bool(name) {

To reproduce

package main

import (
	"github.com/urfave/cli/v2"
	"os"
)

func main() {
	cli.HelpFlag = nil
	app := cli.NewApp()
	_ = app.Run(os.Args)
}

Then panic:

/go/pkg/mod/github.com/urfave/cli/v2@v2.25.7/help.go:419 
@wxiaoguang wxiaoguang added area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this labels Jul 18, 2023
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/bug describes or fixes a bug status/triage maintainers still need to look into this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant