Giter Club home page Giter Club logo

Comments (7)

dag avatar dag commented on June 20, 2024

You want something like, some argument. Have a look at Alternative which the parser is an instance of.

from optparse-applicative.

lambda-fairy avatar lambda-fairy commented on June 20, 2024

Thanks – I've tried using some (argument ...) and (:) <$> argument ... <*> arguments ... and they both share the same problem. When I invoke the program with the --help option, the argument parser gobbles it up, and then my program tries to process it rather than displaying help as it should.

from optparse-applicative.

dag avatar dag commented on June 20, 2024

Ah yea, that issue was fixed in arguments but not argument. I would like the former to be simply something like many argument but perhaps that's non-trivial or not possible for some reason? In the mean time you should be able to work around it by having the reader return Nothing if the argument starts with a hyphen.

from optparse-applicative.

lambda-fairy avatar lambda-fairy commented on June 20, 2024

That works – thank you again.

The inconsistent behavior should probably go in a separate issue, so I'm closing this for now.

from optparse-applicative.

pcapriotti avatar pcapriotti commented on June 20, 2024

The problem here is that arguments has some special logic to:

  • initially ignore arguments starting with '-'
  • accept '--'
  • accept arguments starting with '-' after '--' is encountered

Given this desired behavior, arguments cannot simply be implemented as many argument.

What we can do to make common use cases like the one in this Issue easier to
deal with, is to add a bunch of convenience builders, like:

  • arguments1, non-empty argument list, with the same behavior as arguments
  • argument', parse 1 argument, ignoring things starting with '-'

This way, many argument' would be similar to arguments (without the special
handling of --), and some argument' to arguments1.

Suggestions for better names are welcome. :)

from optparse-applicative.

pcapriotti avatar pcapriotti commented on June 20, 2024

Fixed by 700e07b,

from optparse-applicative.

dag avatar dag commented on June 20, 2024

I'm sort of pondering if this should happen at a lower level, splitting the input before parsing?

from optparse-applicative.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.