Comments (5)
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.
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.
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.
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.
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)
- Delegate completions for a specific argument to the completions of an external program HOT 3
- Visually Separate ArgGroups HOT 2
- Support Base Path for ValueHint::*Path types HOT 1
- Clap-generated shell completion failing on macOS /bin/bash with: conditional binary operator expected: syntax error near `IFS' HOT 3
- `flatten` with `required` breaks requirement checking HOT 1
- `demo.rs` does not compile on its own HOT 4
- Multilingual Help Commands HOT 2
- Environment variable name aliases HOT 1
- Arg dynamic completion via `ValueHint::Execute(String)` HOT 1
- Optional flag argument conflicts with required subcommand HOT 2
- clap_complete: `generate()` shouldn't panic if writing fails
- Make visible_alias print in a way that fits convention HOT 4
- Support multiple positionals with fixed sizes HOT 1
- Hidden subcommands shown when "requires a subcommand but one was not provided" HOT 1
- No clap_derive for latest clap HOT 2
- Add the Ability to Display Visible Aliases for PossibleValues HOT 1
- `ArgAction::Count` starts from `0` rather than `default_value` HOT 6
- Allow API users to deprecate args HOT 1
- Check for group of repeated arguments
- Inconsistencies in short helps (`-h`) use of long help
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clap.