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
Closed
@tilleryd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v2relates to / is being considered for v2kind/questionsomeone asking a questionstatus/triagemaintainers still need to look into this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0