Skip to content

How do I show help text for BoolWithInverseFlags? #2131

Closed

Description

@tilleryd

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

Activity

  1. added
    kind/question
    area/v2
    status/triage
    on May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v2kind/questionstatus/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions