-
Notifications
You must be signed in to change notification settings - Fork 124
Open
Description
It's a fairly common pattern for an option --foo to set some default value, and --foo=val to set some more specific value. (With the equals sign being required before the value; a space is ambiguous in this case.)
I cannot find a way to implement this with optparse-applicative, without renaming one of the options from --foo to --bar.
This code compiles, and usage shows "[--foo ARG] | [--foo]", but parsing "--foo" fails.
data Foo = FooStr String | FooBool Bool
parser = (FooStr <$> strOption (long "foo")) <|> (FooBool <$> switch (long "foo"))
I don't really like that as a way of implementing it even if it worked, due to the redundancy.
Could there be a version of option that takes a default value, for when no value is provided?
(#242 touches on this, but is also about a regression)
chshersh, dino- and ad-si
Metadata
Metadata
Assignees
Labels
No labels