diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index 40026ca4b..1768a5e0c 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -11026,11 +11026,11 @@ static CommandSpec extractCommandSpec(Object command, IFactory factory, boolean injectSpecIntoVersionProvider(result, cmd, factory); result.setAddMethodSubcommands(false); // method commands don't have method subcommands hasCommandAnnotation = true; - initFromMethodParameters(userObject, method, result, null, factory); initSubcommands(cmd, null, result, factory, new Stack>()); // after adding options + result.mixinStandardHelpOptions(cmd.mixinStandardHelpOptions()); // do this last + initFromMethodParameters(userObject, method, result, null, factory); // set command name to method name, unless @Command#name is set result.initName(((Method)command).getName()); - result.mixinStandardHelpOptions(cmd.mixinStandardHelpOptions()); // do this last } else { Stack> hierarchy = new Stack>(); Class cls = userObject.getType(); @@ -11050,9 +11050,9 @@ static CommandSpec extractCommandSpec(Object command, IFactory factory, boolean hasCommandAnnotation = true; mixinStandardHelpOptions |= cmd.mixinStandardHelpOptions(); } - hasCommandAnnotation |= initFromAnnotatedFields(userObject, cls, result, null, factory, null); initSubcommands(cmd, cls, result, factory, originalHierarchy); // after adding options initMethodSubcommands(cls, result, factory); // regardless of @Command annotation. NOTE: after adding options + hasCommandAnnotation |= initFromAnnotatedFields(userObject, cls, result, null, factory, null); } result.mixinStandardHelpOptions(mixinStandardHelpOptions); //#377 Standard help options should be added last }