private static boolean updateCommandAttributes(Command cmd, CommandSpec commandSpec, IFactory factory) { commandSpec.aliases(cmd.aliases()); commandSpec.parser().updateSeparator(cmd.separator()); commandSpec.updateName(cmd.name()); commandSpec.updateVersion(cmd.version()); commandSpec.updateHelpCommand(cmd.helpCommand()); commandSpec.updateVersionProvider(cmd.versionProvider(), factory); commandSpec.initDefaultValueProvider(cmd.defaultValueProvider(), factory); commandSpec.usageMessage().updateFromCommand(cmd, commandSpec); initSubcommands(cmd, commandSpec, factory); return true; } private static void initSubcommands(Command cmd, CommandSpec parent, IFactory factory) {
/** * Updates the following attributes from the specified {@code @Command} annotation: * aliases, {@link ParserSpec#separator() parser separator}, command name, version, help command, * version provider, default provider and {@link UsageMessageSpec usage message spec}. * @param cmd the {@code @Command} annotation to get attribute values from * @param factory factory used to instantiate classes * @since 3.7 */ public void updateCommandAttributes(Command cmd, IFactory factory) { aliases(cmd.aliases()); parser().updateSeparator(cmd.separator()); updateName(cmd.name()); updateVersion(cmd.version()); updateHelpCommand(cmd.helpCommand()); updateAddMethodSubcommands(cmd.addMethodSubcommands()); usageMessage().updateFromCommand(cmd, this); if (factory != null) { updateVersionProvider(cmd.versionProvider(), factory); initDefaultValueProvider(cmd.defaultValueProvider(), factory); } }