Skip to content

Context.IsSet returns false even if StringSlice flag is set #314

Closed

Description

@disktnk

On my environment (mac OS X 10.10.5), Context.IsSet does not work when using StringSliceFlag .

// `cmd` is a "sub_command" object
cmd.Flags = []cli.Flag{
    cli.StringFlag{
        Name:   "string_arg, s",
        Value:  "",
        Usage:  "snip",
    },
    cli.StringSliceFlag{
        Name:  "string_slice_arg, a",
        Value: &cli.StringSlice{},
        Usage: "snip",
    },
}

// ...snip

fmt.Println(c.IsSet("string_arg"))
fmt.Println(c.IsSet("string_slice_arg"))
./go_binary sub_command -s str1 -a str2
true
false

Activity

  1. added
    kind/bug
    on Apr 29, 2016
  2. self-assigned this
    on Apr 29, 2016
  3. meatballhat commented on Apr 29, 2016

    @meatballhat
    Member

    Confirmed! Oddly, I'm seeing different behavior when calling IsSet with "short" vs "long" flag names (see gist). Still investigating...

  4. jszwedko commented on Apr 29, 2016

    @jszwedko
    Contributor

    Hmmm, interesting, seems to have been introduced in #73

  5. meatballhat commented on Apr 29, 2016

    @meatballhat
    Member

    Yeppers. My initial attempt to solve this is made more awkward by the slice types being aliases rather than composites. It might be easiest to address this after the merge of #350.

  6. meatballhat commented on Apr 29, 2016

    @meatballhat
    Member

    I'm going to see if I can tack this bugfix onto #350 yep yep.

  7. added
    status/claimed
    on May 5, 2016
  8. jszwedko commented on May 21, 2016

    @jszwedko
    Contributor

    Fixed by #392 (will be released is v2, but you can use that branch for now if you need the functionality sooner!).

  9. removed
    status/claimed
    on May 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions