Skip to content

Commit a0c8058

Browse files
committed
Improve string parser supplier argument checking
1 parent 897eafb commit a0c8058

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

cloud-core/src/main/java/cloud/commandframework/arguments/parser/StandardParserRegistry.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,21 @@ public StandardParserRegistry() {
152152
final boolean greedy = options.get(StandardParameters.GREEDY, false);
153153
final boolean greedyFlagAware = options.get(StandardParameters.FLAG_YIELDING, false);
154154
final boolean quoted = options.get(StandardParameters.QUOTED, false);
155-
if (greedy && quoted) {
155+
if (greedyFlagAware && quoted) {
156+
throw new IllegalArgumentException(
157+
"Don't know whether to create GREEDY_FLAG_YIELDING or QUOTED StringArgument.StringParser, both specified."
158+
);
159+
} else if (greedy && quoted) {
156160
throw new IllegalArgumentException(
157161
"Don't know whether to create GREEDY or QUOTED StringArgument.StringParser, both specified."
158162
);
159163
}
160164
final StringArgument.StringMode stringMode;
161-
if (greedy) {
162-
stringMode = StringArgument.StringMode.GREEDY;
163-
} else if (greedyFlagAware) {
165+
// allow @Greedy and @FlagYielding to both be true, give flag yielding priority
166+
if (greedyFlagAware) {
164167
stringMode = StringArgument.StringMode.GREEDY_FLAG_YIELDING;
168+
} else if (greedy) {
169+
stringMode = StringArgument.StringMode.GREEDY;
165170
} else if (quoted) {
166171
stringMode = StringArgument.StringMode.QUOTED;
167172
} else {

0 commit comments

Comments
 (0)