Comments (4)
Yeah, positionalList
is not intended to be associated with an option, so it won't do what you're trying to do here.
There is a way to do what you want using the internal option
method. I almost made this method public, but ended up making it internal
before the initial release, as its API is kind of ugly and error-prone, and I didn't want to paint myself into a corner by making it public.
I've also been considering cranking down its power a bit before making it public. Most arg parsing APIs have essentially 3 kinds of options: 0-arg, 1-arg, and 0/1-args (aka non-greedy 1-arg -- see #8 ). Right now options
actually lets an option consume an arbitrary number of arguments, and decide to stop based on the argument values (with a look ahead of 1), even though none of the public helpers actually use this ability beyond consuming a single argument.
One idea I've had for changing it to be less error-prone, while still exposing more power than is currently available, is to make the user (of options
) specify a fixed argument count. Then for your case you'd state that it takes 2-arguments. (I'd also have to special-case the 0/1 non-greedy case.)
In the meantime, would something like a "putting
" method that works like adding
but consumes 2 (instead of 1) args and put
s the key/value pairs into a Map
be good enough for your immediate needs? That would be pretty easy to add, and I think would probably be generally useful.
from kotlin-argparser.
I'm thinking that I'm going to change option
to take an argument count (or possibly an argument name list), and make it public. I'm not going to have a chance to work on this for the next week or so, though.
from kotlin-argparser.
Sorry I've been busy and haven't had a chance to consider either putting
or take a look at optional
. I'm currently doing key=value
and adding
which works, so anything that lets me do the two argument things after a flag is excellent.
from kotlin-argparser.
Version 2.0.0 (just released) makes this possible. I've even added an example in the README (it's also in the tests). Search for "putting" in the README.
from kotlin-argparser.
Related Issues (20)
- Allow '.' as Separator in Options and Arguments HOT 2
- Hierarchical arguments
- Print help when catching SystemExitException HOT 1
- Is it possible to allow number parameters HOT 3
- Incorrect example main function in README.md HOT 1
- Readme example does not work HOT 3
- Exception in thread "main" com.xenomachina.argparser.ShowHelpException: Help was requested HOT 3
- InvalidArgumentName when argument name has trailing digit HOT 2
- Allow escaping strings HOT 6
- Include exception handling in force parse HOT 3
- Make `mainBody` behavior the default when parsing args HOT 3
- Help section titles should be capitalized HOT 2
- Interest in better support for sub parsers HOT 2
- Don't be too strict with positional and positionalList names
- Influcence exit behaviour
- better handling of long parameter names in the default formatter
- Is this project dead? HOT 1
- Support options of the form "-<number>" (hyphen immediately followed by a number)
- JCenter end of life
- kotlin-argparser and native?
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 kotlin-argparser.