Repository navigation
Closed
Labels
area/v3relates to / is being considered for v3kind/bugdescribes or fixes a bugstatus/triagemaintainers still need to look into this
Description
My urfave/cli version is
v3.3.3
Checklist
- Are you running the latest v3 release? The list of releases is here.
- Did you check the manual for your release? The v3 manual is here
- Did you perform a search about this problem? Here's the GitHub guide about searching.
Dependency Management
- My project is using go modules.
Describe the bug
A clear and concise description of what the bug is.
To reproduce
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/urfave/cli/v3"
)
var (
flagCSV = &cli.StringFlag{
Name: "csv",
}
flagFind = &cli.StringFlag{
Name: "find",
}
)
func main() {
cmd := &cli.Command{
Flags: []cli.Flag{
flagCSV,
flagFind,
},
MutuallyExclusiveFlags: []cli.MutuallyExclusiveFlags{
{
Flags: [][]cli.Flag{
{
flagCSV,
},
{
flagFind,
},
},
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
fmt.Println("Hello, world!")
return nil
},
OnUsageError: func(_ context.Context, _ *cli.Command, err error, _ bool) error {
return err
},
}
if err := cmd.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}Command:
go run main.go --find a --csv bObserved behavior
The command errors as expected, but it prints the Usage string alongside the error:
NAME:
main - A new cli application
USAGE:
main
OPTIONS:
--csv string
--find string
--help, -h show help
--csv string
--find string
2025/05/24 16:09:21 option csv cannot be set along with option find
exit status 1Expected behavior
Expected to see the error message alone without the Usage according to the custom OnUsageError:
2025/05/24 16:09:21 option csv cannot be set along with option find
exit status 1
Run go version and paste its output here
go version go1.24.2 linux/amd64
Run go env and paste its output here
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='on'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/ayo/go/bin'
GOCACHE='/home/ayo/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/ayo/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3848299274=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/ayo/dev/random/go.mod'
GOMODCACHE='/home/ayo/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ayo/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/ayo/.local/share/mise/installs/go/1.24.2'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/ayo/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/ayo/.local/share/mise/installs/go/1.24.2/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'
Metadata
Metadata
Assignees
Labels
area/v3relates to / is being considered for v3kind/bugdescribes or fixes a bugstatus/triagemaintainers still need to look into this
Activity