Comments (8)
There isn't currently.
In my $dayjob we have use cases where we want this behaviour, e.g. when building wrappers around other commands, and we legitimately want to be able to pass in things that look like options that are passed through to some underlying process.
That being said you could create a custom restriction to achieve this and I can see this as being a useful feature for other users. I'll put together a PR for this and provide you with a SNAPSHOT build you can test to see if my idea resolves your issue
from airline.
Please see the proposed new @NoOptionLikeValues
annotation in PR #113
I have published a 2.8.4-SNAPSHOT
build that has this proposed change if you wish to try it out, you'll need to point your build to the OSSRH Snapshot Repositories to pick this up
from airline.
Thanks for working on this @rvesse! I tried pulling a snapshot build but couldn't find it. I would expect to find a rvesse
in https://s01.oss.sonatype.org/content/repositories/snapshots/com/github/ but don't.
Am I looking in the wrong place?
from airline.
@reevesg Looks like it's here - https://oss.sonatype.org/content/repositories/snapshots/com/github/rvesse/airline/
from airline.
@rvesse I tried the snapshot build and it works great. Thanks!
When do you think you will release 2.8.4
?
from airline.
@reevesg Possibly next week
One outstanding question is whether it would be useful to be able to use @NoOptionLikeValues
as a global restriction?
i.e. you could specify it at your Command/CLI class level and it would validate that no options/arguments received an option like value
This is as opposed to the current PR proposal whereby you have to manually add it to each @Option
or @Arguments
annotated field you want it to apply to.
Note that making it work as a global restriction would not preclude it still being applied directly to option/argument fields
from airline.
@rvesse sorry for the delay. Yeah I think the global restriction would be best in some cases, but its also really useful as it is.
from airline.
@reevesg I've just pushed out a 2.8.4 release today, this will take a few hours to be visible in Maven Central. Sorry it took so long to get around to this.
Note that I did end up making @NoOptionLikeValues
be usable as a Global Restriction. In further testing I did discover an interesting gotcha with the restriction when applied to options/arguments that might legitimately have an option like prefix e.g. consider -1
passed to an Integer
typed field.
When used directly on an Option/Argument then the restriction applies to the raw unparsed values and so would reject -1
unless you customised the annotation to use different option prefixes.
Whereas when used as a Global Restriction it applies over the parsed typed values and so can ignore anything that isn't a string since the parsing into the type likely already rejects bad values e.g. -typo
would already be an invalid integer.
I've done my best to document this in both the Javadoc for the annotation and the corresponding User Guide page for the annotation. However hopefully this new annotation proves useful and resolves your issue.
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
- Options with non-zero arity and no value supplied can consume other option names instead of producing an error HOT 6
- Add support for Path conversion HOT 3
- 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
- Commands with duplicate names within a group silently override each other HOT 1
- ...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.