go-arg icon indicating copy to clipboard operation
go-arg copied to clipboard

Incorrect behavior of the built-in help message for the help option

Open vanyauhalin opened this issue 2 years ago • 1 comments

Setup

$ cat go.mod
module main

go 1.21.4

require github.com/alexflint/go-arg v1.4.3

require github.com/alexflint/go-scalar v1.1.0 // indirect
$ cat main.go
package main

import (
	arg "github.com/alexflint/go-arg"
)

type options struct {
	Sub *Sub `arg:"subcommand"`
}

type Sub struct {
	A string `arg:"positional"`
}

func main() {
	var opts options
	arg.MustParse(&opts)
}

Actual

$ go run . sub --help
Usage: main sub [A]

Positional arguments:
  A
  --help, -h             display this help and exit

Expected

$ go run . sub --help
Usage: main sub [A]

Positional arguments:
  A

Global options:
  --help, -h             display this help and exit

vanyauhalin avatar Nov 27 '23 05:11 vanyauhalin

Yeah I think you're right. Will look at changing this. Thanks for reporting!

alexflint avatar Mar 02 '24 21:03 alexflint