Comments (6)
Most of the default option parsers are greedy and just attempt to consume the number of values required by the arity of the option without any real inspection of those values. So more specifically to your use case it doesn't try to disambiguate between the next token being a value vs it being another option.
So in your first case it sees --open
and tries to parse a value for it but finds none thus you receive an error
In the second case it sees --open
so grabs the next value which is --debug
so your open
option gets the value --debug
and you don't receive an error
from airline.
But certainly this could be handled better, the default option parsers could check whether the next value is actually an option name and stop parsing further values if it is which should then generate the correct error in both cases
from airline.
So on thinking on this more I thought that the option parsers were supposed to be smart enough to check if the next token was an option and if so not treat it as a value. However it looks like one of the default parsers special cases the logic for arity = 1
to just consume the next token without that check.
So this is definitely a bug that wants fixing and I'll try to get this into the next release
from airline.
Changed needed:
-
ClassicGetOptParser
-
StandardOptionParser
(special cases arity 1 options currently) -
ListValueParser
-
MaybeListValueParser
- Unit test cases for this kind of error covering all built-in option parsers
from airline.
Should now be fully fixed on master
, will push out a new bug-fix release shortly
from airline.
Fixed in 2.8.2 which is now released. It may take a couple of hours for artifacts to show up on Maven Central
from airline.
Related Issues (20)
- Allowed Values restrictions have bugs with case sensitivity
- Options of scope `GLOBAL` and `GROUP` cannot be specified at command level
- List possible enum values in the help for an Option HOT 2
- Add `module-info.java` to all modules HOT 3
- Rename `@com.github.rvesse.airline.annotations.restrictions.File` HOT 4
- option arity
- Add support for Path conversion HOT 3
- Unexpected param isn't thrown if there is an argument HOT 8
- Upgrade inject-api to 2.x HOT 13
- Download link broken HOT 1
- When numeric range restriction is too narrow a type for field type unhelpful errors are issued
- Docs site is not very accessible for color-challenged readers HOT 2
- Find a way to make Prompts not block on timeout
- [Question] Need advice on migrating from io.airlift:airline v0.8 HOT 4
- Provide an option/argument defaulting mechanism
- ...llowedValuesRestrictionFactory not found HOT 14
- ListValueOptionParser is overly strict HOT 2
- Provide support for prompting HOT 2
- Airline incorrectly consumes (i.e. ignores) a value when defaulting in some circumstances HOT 1
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 airline.