diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/parser/StandardParserRegistry.java b/cloud-core/src/main/java/cloud/commandframework/arguments/parser/StandardParserRegistry.java index 64a1b464..c860d940 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/parser/StandardParserRegistry.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/parser/StandardParserRegistry.java @@ -152,16 +152,21 @@ public final class StandardParserRegistry implements ParserRegistry { final boolean greedy = options.get(StandardParameters.GREEDY, false); final boolean greedyFlagAware = options.get(StandardParameters.FLAG_YIELDING, false); final boolean quoted = options.get(StandardParameters.QUOTED, false); - if (greedy && quoted) { + if (greedyFlagAware && quoted) { + throw new IllegalArgumentException( + "Don't know whether to create GREEDY_FLAG_YIELDING or QUOTED StringArgument.StringParser, both specified." + ); + } else if (greedy && quoted) { throw new IllegalArgumentException( "Don't know whether to create GREEDY or QUOTED StringArgument.StringParser, both specified." ); } final StringArgument.StringMode stringMode; - if (greedy) { - stringMode = StringArgument.StringMode.GREEDY; - } else if (greedyFlagAware) { + // allow @Greedy and @FlagYielding to both be true, give flag yielding priority + if (greedyFlagAware) { stringMode = StringArgument.StringMode.GREEDY_FLAG_YIELDING; + } else if (greedy) { + stringMode = StringArgument.StringMode.GREEDY; } else if (quoted) { stringMode = StringArgument.StringMode.QUOTED; } else {