8000 How do I show help text for BoolWithInverseFlags? · Issue #2131 · urfave/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How do I show help text for BoolWithInverseFlags? #2131

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

Closed
tilleryd opened this issue May 12, 2025 · 0 comments · Fixed by #2142
Closed

How do I show help text for BoolWithInverseFlags? #2131

tilleryd opened this issue May 12, 2025 · 0 comments · Fixed by #2142
Labels
area/v2 relates to / is being considered for v2 kind/question someone asking a question status/triage maintainers still need to look into this

Comments

@tilleryd
Copy link
tilleryd commented May 12, 2025

It seems that BoolWithInverseFlags are working as expected with v3.3.3 but I don't see them printed in the help. In the example below I would expect to see --foo under the global options.

Example:

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/urfave/cli/v3"
)

func main() {
	cmd := &cli.Command{
		Flags: []cli.Flag{
			&cli.BoolWithInverseFlag{
				Name:   "foo",
				Value:  false,
				Usage:  "use some foo",
				Hidden: false,
			},
		},
		Action: func(ctx context.Context, cmd *cli.Command) error {
			if cmd.Bool("foo") {
				fmt.Println("foo is set")
			} else {
				fmt.Println("no-foo is set")
			}

			return nil
		},
	}

	if err := cmd.Run(context.Background(), os.Args); err != nil {
		log.Fatal(err)
	}
}

Output:

➜  urfave_v3_test go run main.go -h            
NAME:
   main - A new cli application

USAGE:
   main [global options]

GLOBAL OPTIONS:
   --help, -h  show help

➜  urfave_v3_test go run main.go --foo
foo is set

➜  urfave_v3_test go run main.go --no-foo
no-foo is set
@tilleryd tilleryd added kind/question someone asking a question area/v2 relates to / is being considered for v2 status/triage maintainers still need to look into this labels May 12, 2025
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/triage maintainers still need to look into this
Projects
None yet
1 participant
0