Git Product home page Git Product logo

Comments (5)

kbknapp avatar kbknapp commented on May 30, 2024

I would either set the number of values for --scope if you know how many, I'll also look at evaluating subcommands earlier so as to stop parsing --scope if a subcommand is reached. Currently it only stops if it reaches the max, or exact, number of expected values for --scope, or it reaches another argument starting with -. I can roll this up into #111 too

from clap.

Byron avatar Byron commented on May 30, 2024

Unfortunately I don't - --scope is setup exactly how it needs to be, limiting it would be arbitrary. This issue stems from the simplification which allows me to also specify tiny multi-flags like -r foo=bar snoo=baz only once, which is appreciated too.
But if I'd have to choose, I would choose correct parsing over this convenience.
On the other hand, a proper implementation seems possible, it's just that values for + multi-value flags must not be subcommand names anymore.
If there really is no way, I would probably just make --scope single-value, which is what it had to be in the old-ages of docopt, which had the same problem. Interestingly, argparse in python has the same issue too, and I explicitly hacked my own copy to get rid of that limitation back in the days.

from clap.

kbknapp avatar kbknapp commented on May 30, 2024

No worries, it should be fixed with #111 Once it's merged I'll update crates.io (0.8.1 on crates.io)

from clap.

kbknapp avatar kbknapp commented on May 30, 2024

The newest version should solve the issue for you, and it was a valid bug.

To expand on the issue though; the only thing I can't currently do (and realistically it's probably impossible to do) is tell when a [unlimited] multiple value stops and a positional starts. Because positionals have no specifier (unless you count -- which works, but it also marks all following arguments after that as positional as well). The answer is to either rearrange the arguments (so the positional comes before the multiple values), or use --.

from clap.

Byron avatar Byron commented on May 30, 2024

Thank you ! I have rolled-back my change locally and could verify it works fine.

Regarding the stated problem with positionals (and grammars like prog <x> <y> -m <v>...) which are difficult to parse unless in the right order: I think we just have no technology advanced enough just yet.
Well, actually, it is there, just not for this field: regular expressions. The engine behind that is able to act non-greedily, while maximizing matches for respective terms.
I know no implementation using regex though - maybe because for the most part, arg-parsers could get away with relatively trivial (compared to a regex system) and manual implementations.

Now that I am implementing a simple json lexer to allow me to write a filter to get rid of null values in json streams, I am also thinking that this kind of pattern matching would be totally suited to any kind of token-based system. However, a non-text based regular expression engine is also nowhere to be found. Such a thing would certainly be overkill for what I want to do, but I am lazy and would prefer to write a simple substitution regex which works on my json tokens.

Anyway, thanks again for all the fixes - I believe I am totally happy now, with the CLI at least :).

from clap.

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.