ndmitchell / cmdargs

Haskell library for command line argument processing
Other
91 stars 12 forks source link

Default Lists? #58

Open Chobbes opened 5 years ago

Chobbes commented 5 years ago

Say I have command line arguments, and one of the things that I want to accept is a list of arguments. Let's just use the example from here:

https://zuttobenkyou.wordpress.com/2011/04/19/haskell-using-cmdargs-single-and-multi-mode/

So, I have a list of formats, and I might want to specify several of them.

data Format     = Text
                | TeX
                | HTML
                | FNone
    deriving (Data, Typeable, Show, Eq)

data MyOptions = MyOptions
    { ...
    , format :: [Format]
    , ...
    } deriving (Data, Typeable, Show, Eq)

myProgOpts = MyOptions
    { ...
    , format = [] &= help "format of output"
    , ...
    }

This seems to work well, but when format is, say [TeX] by default (instead of the empty list) I would expect the behavior to be [TeX] when no argument is passed in, but if I do something like... -f Text -f HTML I would expect to get [Text, HTML]. Instead you get a list with [Tex, Text, HTML].

Is this the expected behaviour? Is there any way to get my desired behaviour of [Text, HTML]?

Thanks in advance!