Skip to content

Global flags marked as Local are still recognized after a subcommand #2208

Closed

Description

@folliehiyuki

My urfave/cli version is

cli/v3 v3.4.1

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

Parent flags marked as non-persistent (Local=true) are still recognized when specified after a subcommand.

To reproduce

package main

import (
	"context"
	"log"
	"os"

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

func main() {
	cmd := &cli.Command{
		Name:    "testprog",
		Version: "1.0",
		Commands: []*cli.Command{
			{
				Name: "subcmd",
				Commands: []*cli.Command{
					{
						Name: "nested-subcmd",
						Action: func(ctx context.Context, c *cli.Command) error {
							c.Writer.Write([]byte("The nested subcommand is executed\n"))
							return nil
						},
					},
				},
				Flags: []cli.Flag{
					&cli.StringFlag{
						Name:  "subcmd-flag",
						Local: true,
						Action: func(ctx context.Context, c *cli.Command, v string) error {
							c.Writer.Write([]byte("--subcmd-flag is presented\n"))
							return nil
						},
					},
				},
				Action: func(ctx context.Context, c *cli.Command) error {
					c.Writer.Write([]byte("The subcommand is executed\n"))
					return nil
				},
			},
		},
		Flags: []cli.Flag{
			&cli.BoolFlag{
				Name:  "root-flag",
				Local: true,
				Action: func(ctx context.Context, c *cli.Command, b bool) error {
					c.Writer.Write([]byte("--root-flag is presented\n"))
					return nil
				},
			},
		},
		Action: func(ctx context.Context, c *cli.Command) error {
			c.Writer.Write([]byte("The root command is executed\n"))
			return nil
		},
	}

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

Observed behavior

$ testprog subcmd --root-flag
--root-flag is presented
The subcommand is executed

Expected behavior

The command should produce an error, indicating that the parent flag is invalid in the subcommand context.

$ testprog subcmd --root-flag
Incorrect Usage: flag provided but not defined: -root-flag

2025/10/13 12:00:33 flag provided but not defined: -root-flag

Run go version and paste its output here

go version go1.25.0 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=''
GOCACHE='/home/follie/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/follie/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build580634775=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/follie/orara/go.mod'
GOMODCACHE='/home/follie/.local/share/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/follie/.local/share/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/nix/store/3fd683jfggglpshxprz9mi5sz8wd3c9p-go-1.25.0/share/go'
GOSUMDB='off'
GOTELEMETRY='off'
GOTELEMETRYDIR='/home/follie/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/nix/store/3fd683jfggglpshxprz9mi5sz8wd3c9p-go-1.25.0/share/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.0'
GOWORK=''
PKG_CONFIG='pkg-config'

Activity

  1. added
    kind/bugdescribes or fixes a bug
    status/triagemaintainers still need to look into this
    area/v3relates to / is being considered for v3
    on Oct 13, 2025
  2. dearchap commented on Oct 13, 2025

    @dearchap
    Contributor

    @folliehiyuki there is no concept of global flags in v3. There are only Persistent(apply to current command and subcommands) and non-Persistent/Local flags(which apply only to current command). AFAICS the version flag is set to local so it should not be valid for subcommands. Its perhaps a bug if our processing of version flag. Want to make a fix ?

  3. folliehiyuki commented on Oct 13, 2025

    @folliehiyuki
    Author

    I edited the issue description to be less misleading. The issue occurs to all non-persistent flags in general, not just --version.

  4. folliehiyuki commented on Oct 13, 2025

    @folliehiyuki
    Author

    The trace for the above reproduce command: URFAVE_CLI_TRACING=on testprog subcmd --root-flag >/dev/null

    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:99 (github.com/urfave/cli/v3.(*Command).run) running with arguments ["./testprog" "subcmd" "--root-flag"] (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:20 (github.com/urfave/cli/v3.(*Command).setupDefaults) isRoot? true (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:23 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default ShellComplete (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:34 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default Usage (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:49 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default Reader as os.Stdin (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:54 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default Writer as os.Stdout (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:59 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default ErrWriter as os.Stderr (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:75 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting sub-command (cmd="subcmd") parent as self (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:190 (github.com/urfave/cli/v3.(*Command).ensureHelp) ensuring help (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:179 (github.com/urfave/cli/v3.(*Command).hideHelp) hide help (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:197 (github.com/urfave/cli/v3.(*Command).ensureHelp) appending helpCommand (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:210 (github.com/urfave/cli/v3.(*Command).ensureHelp) appending HelpFlag (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:82 (github.com/urfave/cli/v3.(*Command).setupDefaults) appending version flag (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:110 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting command categories (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:117 (github.com/urfave/cli/v3.(*Command).setupDefaults) sorting command categories (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:120 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting category on mutually exclusive flags (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:125 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting flag categories (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:129 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default Metadata (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:138 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting disableSliceFlagSeparator from cmd.DisableSliceFlagSeparator (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:121 (github.com/urfave/cli/v3.(*Command).run) checking osArgs [./testprog subcmd --root-flag] (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:124 (github.com/urfave/cli/v3.(*Command).run) setting cmd.shellCompletion=false from checkShellCompleteFlag (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:128 (github.com/urfave/cli/v3.(*Command).run) using post-checkShellCompleteFlag arguments ["./testprog" "subcmd" "--root-flag"] (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:130 (github.com/urfave/cli/v3.(*Command).run) setting self as cmd in context (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:145 (github.com/urfave/cli/v3.(*Command).setupCommandGraph) setting up command graph (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:155 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting up self as sub-command (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:190 (github.com/urfave/cli/v3.(*Command).ensureHelp) ensuring help (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:179 (github.com/urfave/cli/v3.(*Command).hideHelp) hide help (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:197 (github.com/urfave/cli/v3.(*Command).ensureHelp) appending helpCommand (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:210 (github.com/urfave/cli/v3.(*Command).ensureHelp) appending HelpFlag (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:159 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting command categories (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:166 (github.com/urfave/cli/v3.(*Command).setupSubcommand) sorting command categories (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:169 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting category on mutually exclusive flags (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:174 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting flag categories (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:145 (github.com/urfave/cli/v3.(*Command).setupCommandGraph) setting up command graph (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:155 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting up self as sub-command (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:190 (github.com/urfave/cli/v3.(*Command).ensureHelp) ensuring help (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:179 (github.com/urfave/cli/v3.(*Command).hideHelp) hide help (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:197 (github.com/urfave/cli/v3.(*Command).ensureHelp) appending helpCommand (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:210 (github.com/urfave/cli/v3.(*Command).ensureHelp) appending HelpFlag (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:159 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting command categories (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:166 (github.com/urfave/cli/v3.(*Command).setupSubcommand) sorting command categories (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:169 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting category on mutually exclusive flags (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:174 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting flag categories (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:145 (github.com/urfave/cli/v3.(*Command).setupCommandGraph) setting up command graph (cmd="nested-subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:155 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting up self as sub-command (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:190 (github.com/urfave/cli/v3.(*Command).ensureHelp) ensuring help (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:179 (github.com/urfave/cli/v3.(*Command).hideHelp) hide help (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:159 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting command categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:166 (github.com/urfave/cli/v3.(*Command).setupSubcommand) sorting command categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:169 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting category on mutually exclusive flags (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:174 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting flag categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:145 (github.com/urfave/cli/v3.(*Command).setupCommandGraph) setting up command graph (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:155 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting up self as sub-command (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:190 (github.com/urfave/cli/v3.(*Command).ensureHelp) ensuring help (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:179 (github.com/urfave/cli/v3.(*Command).hideHelp) hide help (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:159 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting command categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:166 (github.com/urfave/cli/v3.(*Command).setupSubcommand) sorting command categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:169 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting category on mutually exclusive flags (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:174 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting flag categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:145 (github.com/urfave/cli/v3.(*Command).setupCommandGraph) setting up command graph (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:155 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting up self as sub-command (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:190 (github.com/urfave/cli/v3.(*Command).ensureHelp) ensuring help (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:179 (github.com/urfave/cli/v3.(*Command).hideHelp) hide help (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:159 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting command categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:166 (github.com/urfave/cli/v3.(*Command).setupSubcommand) sorting command categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:169 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting category on mutually exclusive flags (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:174 (github.com/urfave/cli/v3.(*Command).setupSubcommand) setting flag categories (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:145 (github.com/urfave/cli/v3.(*Command).setupCommandGraph) setting up command graph (cmd="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:26 (github.com/urfave/cli/v3.(*Command).parseFlags) parsing flags from arguments &{["subcmd" "--root-flag"]} (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:31 (github.com/urfave/cli/v3.(*Command).parseFlags) walking command lineage for persistent flags (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:74 (github.com/urfave/cli/v3.(*Command).parseFlags) parsing flags iteratively tail=["--root-flag"] (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:79 (github.com/urfave/cli/v3.(*Command).parseFlags) rearrange:1 (cmd="testprog") ["subcmd" "--root-flag"]
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:95 (github.com/urfave/cli/v3.(*Command).parseFlags) rearrange-3 (cmd="testprog") check "subcmd"
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:101 (github.com/urfave/cli/v3.(*Command).parseFlags) done parsing flags (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:154 (github.com/urfave/cli/v3.(*Command).run) using post-parse arguments &{["subcmd" "--root-flag"]} (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/help.go:505 (github.com/urfave/cli/v3.checkCompletions) checking completions on command "testprog"
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/help.go:508 (github.com/urfave/cli/v3.checkCompletions) completion not enabled skipping "testprog"
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:176 (github.com/urfave/cli/v3.(*Command).checkHelp) checking if help is wanted (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:353 (github.com/urfave/cli/v3.(*Command).lFlag) flag found for name "help" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:524 (github.com/urfave/cli/v3.(*Command).Value) value found for name "help" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_bool.go:29 (github.com/urfave/cli/v3.(*Command).Bool) bool available for flag name "help" with value=false (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:353 (github.com/urfave/cli/v3.(*Command).lFlag) flag found for name "h" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:524 (github.com/urfave/cli/v3.(*Command).Value) value found for name "h" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_bool.go:29 (github.com/urfave/cli/v3.(*Command).Bool) bool available for flag name "h" with value=false (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:196 (github.com/urfave/cli/v3.(*Command).run) no help is wanted (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:353 (github.com/urfave/cli/v3.(*Command).lFlag) flag found for name "version" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:524 (github.com/urfave/cli/v3.(*Command).Value) value found for name "version" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_bool.go:29 (github.com/urfave/cli/v3.(*Command).Bool) bool available for flag name "version" with value=false (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:353 (github.com/urfave/cli/v3.(*Command).lFlag) flag found for name "v" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:524 (github.com/urfave/cli/v3.(*Command).Value) value found for name "v" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_bool.go:29 (github.com/urfave/cli/v3.(*Command).Bool) bool available for flag name "v" with value=false (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_impl.go:117 (github.com/urfave/cli/v3.(*FlagBase[...]).PostParse) postparse (flag="root-flag")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_impl.go:117 (github.com/urfave/cli/v3.(*FlagBase[...]).PostParse) postparse (flag="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_impl.go:117 (github.com/urfave/cli/v3.(*FlagBase[...]).PostParse) postparse (flag="version")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:237 (github.com/urfave/cli/v3.(*Command).run) checking positional args &{["subcmd" "--root-flag"]} (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:241 (github.com/urfave/cli/v3.(*Command).run) using first positional argument as sub-command name="subcmd" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:273 (github.com/urfave/cli/v3.(*Command).run) running sub-command "subcmd" with arguments &{["subcmd" "--root-flag"]} (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:99 (github.com/urfave/cli/v3.(*Command).run) running with arguments ["subcmd" "--root-flag"] (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:20 (github.com/urfave/cli/v3.(*Command).setupDefaults) isRoot? false (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:23 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default ShellComplete (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:39 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting HideVersion=true due to empty Version (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:49 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default Reader as os.Stdin (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:54 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default Writer as os.Stdout (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:59 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default ErrWriter as os.Stderr (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:75 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting sub-command (cmd="nested-subcmd") parent as self (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:75 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting sub-command (cmd="help") parent as self (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:190 (github.com/urfave/cli/v3.(*Command).ensureHelp) ensuring help (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:179 (github.com/urfave/cli/v3.(*Command).hideHelp) hide help (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:210 (github.com/urfave/cli/v3.(*Command).ensureHelp) appending HelpFlag (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:110 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting command categories (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:117 (github.com/urfave/cli/v3.(*Command).setupDefaults) sorting command categories (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:120 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting category on mutually exclusive flags (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:125 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting flag categories (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:129 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting default Metadata (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_setup.go:138 (github.com/urfave/cli/v3.(*Command).setupDefaults) setting disableSliceFlagSeparator from cmd.DisableSliceFlagSeparator (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:103 (github.com/urfave/cli/v3.(*Command).run) setting parent (cmd="testprog") command from context.Context value (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:128 (github.com/urfave/cli/v3.(*Command).run) using post-checkShellCompleteFlag arguments ["subcmd" "--root-flag"] (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:130 (github.com/urfave/cli/v3.(*Command).run) setting self as cmd in context (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:26 (github.com/urfave/cli/v3.(*Command).parseFlags) parsing flags from arguments &{["--root-flag"]} (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:31 (github.com/urfave/cli/v3.(*Command).parseFlags) walking command lineage for persistent flags (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:34 (github.com/urfave/cli/v3.(*Command).parseFlags) checking ancestor command="testprog" for persistent flags (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:44 (github.com/urfave/cli/v3.(*Command).parseFlags) skipping non-persistent flag ["root-flag"] (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:44 (github.com/urfave/cli/v3.(*Command).parseFlags) skipping non-persistent flag ["help" "h"] (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:44 (github.com/urfave/cli/v3.(*Command).parseFlags) skipping non-persistent flag ["version" "v"] (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:74 (github.com/urfave/cli/v3.(*Command).parseFlags) parsing flags iteratively tail=[] (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:79 (github.com/urfave/cli/v3.(*Command).parseFlags) rearrange:1 (cmd="subcmd") ["--root-flag"]
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:128 (github.com/urfave/cli/v3.(*Command).parseFlags) parseFlags (shortOptionHandling=%!q(bool=false))
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:132 (github.com/urfave/cli/v3.(*Command).parseFlags) flagName:1 (fName="root-flag")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:138 (github.com/urfave/cli/v3.(*Command).parseFlags) flagName:2 (fName="root-flag") (fVal="")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:353 (github.com/urfave/cli/v3.(*Command).lFlag) flag found for name "root-flag" (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:143 (github.com/urfave/cli/v3.(*Command).parseFlags) Trying flag type (fName="root-flag") (type=*cli.FlagBase[bool,github.com/urfave/cli/v3.BoolConfig,github.com/urfave/cli/v3.boolValue])
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:148 (github.com/urfave/cli/v3.(*Command).parseFlags) parse Apply bool flag (fName="root-flag") (fVal="true")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_impl.go:160 (github.com/urfave/cli/v3.(*FlagBase[...]).Set) apply (flag="root-flag")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:211 (github.com/urfave/cli/v3.(*Command).parseFlags) returning-2 (cmd="subcmd") args []
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_parse.go:212 (github.com/urfave/cli/v3.(*Command).parseFlags) done parsing flags (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:154 (github.com/urfave/cli/v3.(*Command).run) using post-parse arguments &{["--root-flag"]} (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/help.go:505 (github.com/urfave/cli/v3.checkCompletions) checking completions on command "subcmd"
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/help.go:508 (github.com/urfave/cli/v3.checkCompletions) completion not enabled skipping "subcmd"
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:176 (github.com/urfave/cli/v3.(*Command).checkHelp) checking if help is wanted (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:353 (github.com/urfave/cli/v3.(*Command).lFlag) flag found for name "help" (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:524 (github.com/urfave/cli/v3.(*Command).Value) value found for name "help" (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_bool.go:29 (github.com/urfave/cli/v3.(*Command).Bool) bool available for flag name "help" with value=false (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:353 (github.com/urfave/cli/v3.(*Command).lFlag) flag found for name "h" (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:524 (github.com/urfave/cli/v3.(*Command).Value) value found for name "h" (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_bool.go:29 (github.com/urfave/cli/v3.(*Command).Bool) bool available for flag name "h" with value=false (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:196 (github.com/urfave/cli/v3.(*Command).run) no help is wanted (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_impl.go:117 (github.com/urfave/cli/v3.(*FlagBase[...]).PostParse) postparse (flag="subcmd-flag")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/flag_impl.go:117 (github.com/urfave/cli/v3.(*FlagBase[...]).PostParse) postparse (flag="help")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:308 (github.com/urfave/cli/v3.(*Command).run) running flag actions (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:544 (github.com/urfave/cli/v3.(*Command).runFlagActions) runFlagActions
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:308 (github.com/urfave/cli/v3.(*Command).run) running flag actions (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:544 (github.com/urfave/cli/v3.(*Command).runFlagActions) runFlagActions
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:392 (github.com/urfave/cli/v3.(*Command).checkRequiredFlags) checking for required flags (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:408 (github.com/urfave/cli/v3.(*Command).checkRequiredFlags) all required flags set (cmd="subcmd")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:392 (github.com/urfave/cli/v3.(*Command).checkRequiredFlags) checking for required flags (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:408 (github.com/urfave/cli/v3.(*Command).checkRequiredFlags) all required flags set (cmd="testprog")
    ## URFAVE CLI TRACE /home/follie/.local/share/go/pkg/mod/github.com/urfave/cli/[email protected]/command_run.go:349 (github.com/urfave/cli/v3.(*Command).run) returning deferErr (cmd="subcmd") %!q(<nil>)
    
  5. changed the title [-]Global flags marked as Local are still regconized after a subcommand[/-] [+]Global flags marked as Local are still recognized after a subcommand[/+] on Oct 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/v3relates to / is being considered for v3kind/bugdescribes or fixes a bugstatus/triagemaintainers still need to look into this

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions