Skip to content

cli.StringSliceFlag and default value #160

@vieux

Description

@vieux

Hello,
I define my flag as follow:

flFilter = cli.StringSliceFlag{
        Name:  "filter",
        Value: &cli.StringSlice{"flag1", "flag2", "flag3"},
}

If I start my binary without arguments, c.StringSlice("filter") returns ["flag1", "flag2", "flag3"] as expected.
If I start my binary with --filter flag4, c.StringSlice("filter") returns ["flag1", "flag2", "flag3", "flag4"]. I find this behaviour odd, I expected it to erase the default value.
Even worst, if I start my binary with --filter flag1, c.StringSlice("filter") returns ["flag1", "flag2", "flag3", "flag1"].

Is this the expected behavior ? I know I have 3 default value so I can do c.StringSlice("filter")[3:] if set, but still it's not perfect.

Metadata

Metadata

Assignees

Labels

kind/bugdescribes or fixes a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions