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

"arguments" swallows options #6

Closed
dag opened this issue Jul 11, 2012 · 3 comments
Closed

"arguments" swallows options #6

dag opened this issue Jul 11, 2012 · 3 comments
Assignees
Milestone

Comments

@dag
Copy link
Contributor

dag commented Jul 11, 2012

If "arguments" isn't the last argument in the applicative declaration it swallows all options (including --hyphenated ones etc). I'm not sure whether this is a bug or a limitation of applicative?

I suppose a work around if you don't want to reorder your data structure is to use some helper function instead of applying your data constructor directly. But if this isn't about a limitation of applicative it would be nice to need no such workarounds! :)

@ghost ghost assigned pcapriotti Jul 11, 2012
@pcapriotti
Copy link
Owner

There a few ways to work around this:

  • Use the new arrow interface (in 0.1.1) to move the arguments parser to the
    end, regardless of the position of the corresponding field in the parsed
    record.

  • Pass a custom reader to arguments that ignores things that look like
    arguments. For example:

    str' :: String -> Maybe String
    str' ('-':_) = Nothing
    str' x = Just x

This should really be integrated into arguments, however.

@dag
Copy link
Contributor Author

dag commented Jul 20, 2012

It's also common to have -- mark "end of flags", so could be nice if arguments supported that convention as well. That is, -- --hyphenated still parses into ["--hyphenated"].

@pcapriotti
Copy link
Owner

Yes, that should be supported as well.

At the moment, you can emulate it by adding a subparser with a single command "--" returning the same argument parser, but it's a bit of a hack, and you get a weird -- in the help page, which is not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants