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
When a CommandSpec is injected into a @Mixin class, the CommandSpec.commandLine() method returns null.
CommandSpec
@Mixin
CommandSpec.commandLine()
This prevents custom setter methods from throwing ParameterExceptions, since the exception constructor requires a not-null CommandLine object.
ParameterExceptions
CommandLine
static class ExampleMixin { @Spec CommandSpec spec; @Option(names = "--trex") void setTRexFences(final String value) { throw new CommandLine.ParameterException(spec.commandLine(), "Didn't say the magic word."); } } static class ExampleCommand implements Callable<Void> { @Spec CommandSpec spec; @Option(names = "--raptor") void setRaptorFences(final String value) { throw new CommandLine.ParameterException(spec.commandLine(), "Didn't say the magic word."); } @Mixin ExampleMixin mixin; @Override public Void call() throws Exception { return null; } } public static void main(String[] args) { CommandLine.call(new ExampleCommand(), args); }
When run with --raptor off (an option in the root Callable):
--raptor off
Callable
Didn't say the magic word.
When run with --trex off (an option in the mixin):
--trex off
Could not invoke void com.zegelin.SpecRepro$ExampleMixin.setTRexFences(java.lang.String) with off
The InvocationTargetException cause is a NPE, from the assert @ CommandLine.java:8852, since the spec commandline is null.
InvocationTargetException
CommandLine.java:8852
Version: 3.5.0
The text was updated successfully, but these errors were encountered:
Thanks for the bug report! I overlooked this use case. :-( I’ll look into it as soon as I can.
Sorry, something went wrong.
dc2b2fc
Fixed in master. I will do a release for this now.
The fix is included in piococli-3.5.1. Enjoy!
No branches or pull requests
When a
CommandSpec
is injected into a@Mixin
class, theCommandSpec.commandLine()
method returns null.This prevents custom setter methods from throwing
ParameterExceptions
, since the exception constructor requires a not-nullCommandLine
object.When run with
--raptor off
(an option in the rootCallable
):When run with
--trex off
(an option in the mixin):The
InvocationTargetException
cause is a NPE, from the assert @CommandLine.java:8852
, since the spec commandline is null.Version: 3.5.0
The text was updated successfully, but these errors were encountered: