Skip to content

Default value not taken into account for BoolWithInverseFlag #2137

Closed

Description

@greg0ire

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

The default value does not seem to be taken into account when using BoolWithInverseFlag

To reproduce

			&cli.BoolWithInverseFlag{
				Name:  "my-flag",
				Value: true,
			},
…
fmt.Println(command.Bool('my-flag')) // this prints false when omitting the flag

Observed behavior

Running the command with no-my-flag or my-flag works as expected, but omitting the flag altogether prints false

Expected behavior

I would expect true being printed

Additional context

BoolFlag behaves properly

Want to fix this yourself?

We'd love to have more contributors on this project! If the fix for
this bug is easily explained and very small, feel free to create a
pull request for it.

Run go version and paste its output here

go version go1.24.3 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=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/gregoire/.local/share/mise/installs/go/1.24.3/bin'
GOCACHE='/home/gregoire/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/gregoire/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2772191193=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/gregoire/workspace/ms.indexer/go.mod'
GOMODCACHE='/home/gregoire/dev/go/pkg/mod'
GONOPROXY='git.manomano.tech'
GONOSUMDB='git.manomano.tech'
GOOS='linux'
GOPATH='/home/gregoire/dev/go'
GOPRIVATE='git.manomano.tech'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/gregoire/.local/share/mise/installs/go/1.24.3'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/gregoire/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/gregoire/.local/share/mise/installs/go/1.24.3/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.3'
GOWORK=''
PKG_CONFIG='pkg-config'

Activity

  1. added
    kind/bug
    status/triage
    area/v3
    on May 19, 2025
  2. changed the title [-]your bug title goes here[/-] [+]Default value not taken into account for BoolWithInverseFlag[/+] on May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v3kind/bugstatus/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions