urfave / cli

A simple, fast, and fun package for building command line apps in Go
https://cli.urfave.org
MIT License
21.9k stars 1.69k forks source link

[v3] Missing `Required` flags show alias rather than primary name #1838

Closed zx8 closed 6 months ago

zx8 commented 6 months ago

Info:

Code

package main

import (
  "context"
  "log"
  "os"

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

func main() {
  cmd := &cli.Command{
    Name: "example",
    Flags: []cli.Flag{
      &cli.StringFlag{
        Name:     "foo",
        Aliases:  []string{"bar"},
        Required: true,
      },
    },
  }

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

Expected

$ go run .
<snip>
Required flag "foo" not set

Actual

$ go run .
<snip>
Required flag "bar" not set
dearchap commented 6 months ago

@zx8 can you test with PR fix ?

zx8 commented 6 months ago

@dearchap Confirmed the linked PR fixes the issue. 👍