I understand that the intent of originallyRequired is to preserve the original user-provided required setting. However, it seems that originallyRequired does not actually preserve the original required setting:
https://github.com/remkop/picocli/blob/121646e408bfee65f70875a6ddb94e16e83d958c/src/main/java/picocli/CommandLine.java#L10445-L10447
//Keep initial required as originallyRequired for Issue#1380 https://github.com/remkop/picocli/issues/1380
arg.originallyRequired = true;
arg.required = true;
Here the code probably should have said
//Keep initial required as originallyRequired for Issue#1380 https://github.com/remkop/picocli/issues/1380
arg.originallyRequired = arg.required;
arg.required = true;
Additionally, the Builder should set originallyRequired when it sets required:
https://github.com/remkop/picocli/blob/121646e408bfee65f70875a6ddb94e16e83d958c/src/main/java/picocli/CommandLine.java#L9570-L9574
Builder(Option option, IAnnotatedElement annotatedElement, IFactory factory) {
this(annotatedElement);
arity = Range.optionArity(annotatedElement);
required = option.required();
https://github.com/remkop/picocli/blob/121646e408bfee65f70875a6ddb94e16e83d958c/src/main/java/picocli/CommandLine.java#L9606-L9610
Builder(Parameters parameters, IAnnotatedElement annotatedElement, IFactory factory) {
this(annotatedElement);
arity = Range.parameterArity(annotatedElement);
required = arity.min > 0; //but arity may still be unresolved...
I understand that the intent of
originallyRequiredis to preserve the original user-providedrequiredsetting. However, it seems thatoriginallyRequireddoes not actually preserve the originalrequiredsetting:https://github.com/remkop/picocli/blob/121646e408bfee65f70875a6ddb94e16e83d958c/src/main/java/picocli/CommandLine.java#L10445-L10447
Here the code probably should have said
Additionally, the
Buildershould setoriginallyRequiredwhen it setsrequired:https://github.com/remkop/picocli/blob/121646e408bfee65f70875a6ddb94e16e83d958c/src/main/java/picocli/CommandLine.java#L9570-L9574
https://github.com/remkop/picocli/blob/121646e408bfee65f70875a6ddb94e16e83d958c/src/main/java/picocli/CommandLine.java#L9606-L9610