urfave/cli

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

zx8 opened this issue · 2 comments

zx8 commented

Info:

  • Using v3.0.0-alpha7

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

@zx8 can you test with PR fix ?

zx8 commented

@dearchap Confirmed the linked PR fixes the issue. 👍