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] Long flag usage text uses short flag syntax #1841

Closed zx8 closed 6 months ago

zx8 commented 6 months ago

This is a very minor annoyance, but worth fixing I think. Short flag syntax is -e and long flag syntax is --example.

The help text for missing flags should use the long flag syntax, as this is pretty standard across all CLI tools that support short flags as well as long flags.


Info:

Code

package main

import (
  "context"
  "log"
  "os"

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

func main() {
  cmd := &cli.Command{
    Name: "example",
  }

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

Expected

$ go run . --bar
flag provided but not defined: --bar

Actual

$ go run . --bar
flag provided but not defined: -bar
dearchap commented 6 months ago

@zx8 Yes this is a very old issue/request. This is the error that the golang flag library returns. Until we move away from that library its unlikely we will fix it.

zx8 commented 6 months ago

Ahh right, ok, so nothing to do with v3 – closing!