You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But found the behavior that when I define the options, the parent command(parent/child are relevant to the mixee command level) 's @Mixin instance's option will not be invoked at all.
For example, I have command A(toplevel), B(subCommand), C(subsubCommand), all of them has declare d@Mixin InputOptions inputOptions.
Cases:
Running A B -e XX C, setEnv in InputOptions of A is not called at all, but C's InputOptionssetEnv in called.
Running A B C -e XX, setEnv of InputOptions in both A and B is not called at all.
Worth to notice, setRegion has been called in all InputOptions instances in both 2 cases above.
Is this some misbehaving in picocli? I was expecting in any cases, the setters method should be called in all InputOptions options. Thus the default value can be set for the options.
The text was updated successfully, but these errors were encountered:
Hi, sorry for the late response.
Can you run your program with tracing set to DEBUG (e.g. use system property -Dpicocli.trace=DEBUG)
and post the output here please?
Thank you for raising this. It looks like you have found a bug.
For the input A B C -e XX, the default value should be applied to setEnv for the A and the B commands, but as you say, this method is only called for C with the command line value "XX".
It looks like the bug is due to the implementation of equals on OptionSpec. As a result, the OptionSpec instance for the --env option in the mixin for A is considered equal to the instance in the B command and in the C command.
Since the --env option was assigned a value "XX" for the C command, it won't assign the default value any more.
The bug means that picocli thinks that the --env option instance in C is the same instance as in the A and B commands, so those are not assigned the default value either, which is incorrect.
Behavior: Setter method annotated by @option with default value not been invoked when reusing it(By saving reusing, I leveraged
@Mixin
).For example:
I have a
@Mixin
class has bunch optionsI reused this options in other commands(in parents and subcommands as global options, I referred example: https://picocli.info/#_use_case_configure_log_level_with_a_global_option)
But found the behavior that when I define the options, the parent command(
parent/child
are relevant to the mixee command level) 's@Mixin
instance's option will not be invoked at all.For example, I have command A(
toplevel
), B(subCommand
), C(subsubCommand
), all of them has declare d@Mixin InputOptions inputOptions
.Cases:
A B -e XX C
,setEnv
inInputOptions
of A is not called at all, but C'sInputOptions
setEnv
in called.A B C -e XX
,setEnv
ofInputOptions
in both A and B is not called at all.Worth to notice,
setRegion
has been called in allInputOptions
instances in both 2 cases above.Is this some misbehaving in picocli? I was expecting in any cases, the setters method should be called in all
InputOptions
options. Thus the default value can be set for the options.The text was updated successfully, but these errors were encountered: