We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Needed for #258.
CommandSpec.forAnnotatedObject requires at least one picocli annotation on the specified object.
CommandSpec.forAnnotatedObject
To allow mixing groovy.cli and picocli annotations, a factory method is needed that allows picocli annotation to be optional.
groovy.cli
The text was updated successfully, but these errors were encountered:
[#316] Enhancement: Support lenient mode where annotations are option…
06fc6bb
…al when extracting annotations.
Index: src/test/java/picocli/CommandLineModelTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/test/java/picocli/CommandLineModelTest.java (revision ) +++ src/test/java/picocli/CommandLineModelTest.java (revision ) @@ -906,4 +906,37 @@ assertTrue(spec.options().isEmpty()); assertFalse(spec.mixinStandardHelpOptions()); } + + @Test + public void testCommandSpec_forAnnotatedObject_requiresPicocliAnnotation() { + try { + CommandSpec.forAnnotatedObject(new Object()); + fail("Expected error"); + } catch (InitializationException ok) { + assertEquals("java.lang.Object is not a command: it has no @Command, @Option, @Parameters or @Unmatched annotations", ok.getMessage()); + } + } + + @Test + public void testCommandSpec_forAnnotatedObjectLenient_doesNotRequirePicocliAnnotation() { + CommandSpec.forAnnotatedObjectLenient(new Object()); // no error + } + + @Test + public void testCommandSpec_forAnnotatedObjectLenient_returnsEmptyCommandSpec() { + CommandSpec spec = CommandSpec.forAnnotatedObjectLenient(new Object()); + assertTrue(spec.optionsMap().isEmpty()); + assertTrue(spec.posixOptionsMap().isEmpty()); + assertTrue(spec.options().isEmpty()); + assertTrue(spec.positionalParameters().isEmpty()); + assertTrue(spec.unmatchedArgsBindings().isEmpty()); + assertTrue(spec.subcommands().isEmpty()); + assertTrue(spec.mixins().isEmpty()); + assertTrue(spec.requiredArgs().isEmpty()); + assertFalse(spec.mixinStandardHelpOptions()); + assertFalse(spec.helpCommand()); + assertEquals("<main class>", spec.name()); + assertArrayEquals(new String[0], spec.version()); + assertNull(spec.versionProvider()); + } }
Sorry, something went wrong.
5035471
No branches or pull requests
Needed for #258.
CommandSpec.forAnnotatedObject
requires at least one picocli annotation on the specified object.To allow mixing
groovy.cli
and picocli annotations, a factory method is needed that allows picocli annotation to be optional.The text was updated successfully, but these errors were encountered: