-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
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
Custom Type Converters are missing for repeated subcommands #1007
Comments
Thank you for raising this! |
Good catch! |
It turns out that the scope of this issue is quite large and not limited to just custom type converter registration. Any programmatic change to a Fixed so farWith the fixes I made so far, repeatable subcommands will now correctly pick up any programmatic changes made via public
RemainingWhat is remaining is that repeatable subcommands will not correctly pick up Applications that programmatically add subcommands or mixins, or build I created #1010 as a separate ticket for that follow-up work. |
Thanks a lot for the fast fix.
I was realizing that on your first commit. I'm assuming that you want to create a new copy to have a new command-object available to set the fields on, in order for it to be executed with the Does it make sense to split the configuration and internal representation from the state (which might need a larger refactoring and thus nothing to consider before 5.0)? I am thinking to postpone the population of the command fields/parameters just before the execution through the I am basing this on code for picocli:4.2.0 as presented by the IDE, thus it might be out of date. Secondly, I am only skimming over the code and might not fully understand each implication. |
Sure, let's keep the scope of this ticket minimal. It already blew the expected amount of work. |
…all attributes in repeatable subcommands
Description
When using the newly introduced repeatable subcommands, I encountered that all custom registered type converters for the current
CommandLine
goes missing when trying to parse a subcommand with a custom type.While this is fine for only one command, it will fail when using repeated subcommands (see example below).
I first thought that this is might be related to the fact that the converters are not registered for subcommands which are added afterwards. However, while debugging, all subcommands are correctly identified and parsed prior to adding the converter. Thus I think, that this is not the intended behavior.
Demo
In my original code, I use a
@Mixin
to provide the options and parameters.Example
Working
Input:
Output:
Failing
Input:
Output:
Workaround
Simply add the converter on the option.
Potential Fix
While the initial subcommand retrieved in
CommandLine:L11590
holds all custom converters, they are not copied over when a result is present (i.e. the subcommand has already been parsed) and a new a new CommandLine is forked:CommandLine:L11595
. Thus it seems necessary to simply copy over theconverterRegistry
or introduce a properCommandLine#copy
-method.Specs
picocli-version: 4.2.0
java-version: OpenJDK14
The text was updated successfully, but these errors were encountered: