Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli.StringSliceFlag and default value #160

Closed
vieux opened this issue Dec 16, 2014 · 6 comments
Closed

cli.StringSliceFlag and default value #160

vieux opened this issue Dec 16, 2014 · 6 comments
Assignees
Labels
kind/bug describes or fixes a bug

Comments

@vieux
Copy link
Contributor

vieux commented Dec 16, 2014

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.

@jszwedko
Copy link
Contributor

jszwedko commented Jan 8, 2015

Mmm this definitely feels unexpected to me.

@icexin
Copy link

icexin commented Dec 10, 2015

EnvVar of StringSlice also has this behavior.

@huguesalary
Copy link

I also have this issue and also feels this behavior is completely unexpected. Is there any plans on fixing this?

I'll see if I can take a stab at it and do a PR too.

@meatballhat meatballhat added the kind/bug describes or fixes a bug label Mar 8, 2016
@meatballhat meatballhat self-assigned this Mar 8, 2016
@jszwedko jszwedko assigned meatballhat and unassigned meatballhat Mar 20, 2016
@jszwedko
Copy link
Contributor

I'd be happy to review a PR for this @huguesalary !

@jinhao
Copy link

jinhao commented Mar 23, 2016

I also hava this issue, expect to change this behavior.

@jszwedko
Copy link
Contributor

Fixed by #392 (will be released is v2, but you can use that branch for now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug describes or fixes a bug
Projects
None yet
Development

No branches or pull requests

7 participants