Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion command_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (cmd *Command) parseFlags(args Args) (Args, error) {
pCmd.Name, cmd.Name,
)

for _, fl := range pCmd.Flags {
for _, fl := range pCmd.allFlags() {
flNames := fl.Names()

pfl, ok := fl.(LocalFlag)
Expand Down
37 changes: 37 additions & 0 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5417,3 +5417,40 @@ func TestCommand_ParallelRun(t *testing.T) {
})
}
}

func TestCommand_ExclusiveFlagsPersistentPropagation(t *testing.T) {
var subCmdAlphaValue string

cmd := &Command{
Name: "root",
MutuallyExclusiveFlags: []MutuallyExclusiveFlags{
{
Flags: [][]Flag{
{
&StringFlag{
Name: "alpha",
},
},
{
&StringFlag{
Name: "beta",
},
},
},
},
},
Commands: []*Command{
{
Name: "sub",
Action: func(_ context.Context, cmd *Command) error {
subCmdAlphaValue = cmd.String("alpha")
return nil
},
},
},
}

err := cmd.Run(buildTestContext(t), []string{"root", "sub", "--alpha", "hello"})
require.NoError(t, err)
assert.Equal(t, "hello", subCmdAlphaValue)
}
2 changes: 1 addition & 1 deletion docs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ require (

require (
github.com/BurntSushi/toml v1.5.0 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/stretchr/testify v1.11.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
1 change: 1 addition & 0 deletions docs/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2 h1:j4SaBpPB8++L0c0KuTnz/Yus3UQoWJ54hQjhIMW8rCM=
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2/go.mod h1:Q79oyIY/z4jtzIrKEK6MUeWC7/szGr46x4QdOaOAIWc=
github.com/urfave/cli-altsrc/v3 v3.0.1 h1:v+gHk59syLk8ao9rYybZs43+D5ut/gzj0omqQ1XYl8k=
Expand Down