-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
How to use a custom CLI flag separator #1878
Comments
not setting a |
|
Can you try WithSeparatorSpec on the string slice flag ? |
could you give me a code hint for |
https://github.com/urfave/cli/blob/v2-maint/flag_string_slice.go#L181 Are you using the latest v2 release ? |
yes I do, v2.27.0 I still believe this is a syntax thing on my side func GetCliFlags() []cli.Flag {
return []cli.Flag{
&cli.StringSliceFlag{
Name: "groups",
Value: cli.NewStringSlice("this,that,other", "foo"),
Usage: "Groups, can be given multiple times",
WithSeparatorSpec: cli.separatorSpec{sep: ";"},
}
} |
Ah no you need to do
|
Thanks for the hint, but it does not work as ./first.go:90:34: separatorSpec not exported by package cli
./first.go:90:48: unknown field 'sep' in struct literal of type cli.separatorSpec I'll stay with v2, keep the setting globally and use no default value |
I'm new to Go so please bare with me.
I have an application which accepts multiple
--groups
flags by usingStringSliceFlag
which works great.I can use it with
fancy_name --groups="asdf" --groups="qwertz"
and get[asdf qwertz]
.As soon as the value of the args contains a
,
it does the right thing and splits it at the comma.fancy_name --groups="asdf,foo" --groups="qwertz"
becomes[asdf foo qwertz]
but I would need[asdf,foo qwertz]
. This is where #1241 and #1134 becomes interesting. I already tried to setapp.SliceFlagSeparator = ";"
but this has no effect on the flag parsing. Changing thedefaultSliceFlagSeparator
inflag.go
to e.g.;
solved the problem of course.So my question in the end is how to set a slice separator for all or a specific flag
The text was updated successfully, but these errors were encountered: