/** * Returns an option representation of this command, that may be used in help generation or exposing the command * in a CLI parser. * * @return option representation of this command. * @since 0.21 */ public OptionMetadata asOption() { // TODO: cache the value? // using getters instead of vars ; some getters have logic return OptionMetadata.builder(getName()).shortName(getShortName()).description(getDescription()).build(); }
OptionMetadata createConfigOption() { return OptionMetadata .builder(CliConfigurationSource.CONFIG_OPTION, "Specifies YAML config location, which can be a file path or a URL.") .valueRequired("yaml_location").build(); }
public HelpCommand(BootLogger bootLogger, Provider<HelpGenerator> helpGeneratorProvider) { super(CommandMetadata.builder(HelpCommand.class).description("Prints this message.").build()); this.bootLogger = bootLogger; this.helpGeneratorProvider = helpGeneratorProvider; }
public HelpConfigCommand(BootLogger bootLogger, Provider<ConfigHelpGenerator> helpGeneratorProvider) { super(CommandMetadata .builder(HelpConfigCommand.class) .description("Prints information about application modules and their configuration options.") .shortName('H')); this.bootLogger = bootLogger; this.helpGeneratorProvider = helpGeneratorProvider; }
/** * Returns application name that is the name of the main class derived from runtime stack. * * @return application name that is the name of the main class derived from runtime stack. */ static String appNameFromRuntime() { Class<?> main = mainClass(); String name = appNameFromJar(main); return name != null ? name : appNameFromClassName(main); }
public Builder defaultName() { return name(ApplicationIntrospector.appNameFromRuntime()); }
/** * Marks value optional and sets the default value for this option that will be used if the option is provided on * command line without an explicit value. * * @param valueName a description of value * @param defaultValue a default value for the option. * @return this builder instance * @since 1.0.RC1 */ public Builder valueOptionalWithDefault(String valueName, String defaultValue) { this.option.defaultValue = defaultValue; return valueOptional(valueName); }
public static Builder builder() { return new Builder().defaultName(); }
public static Builder builder(Class<? extends Command> commandType) { return new Builder().commandType(commandType); }
public CommandMetadata build() { validateName(command.name); return command; }
public Builder name(String name) { this.option.name = validateName(name); return this; }
/** * Marks value optional and sets the default value for this option that will be used if the option is provided on * command line without an explicit value. * * @param defaultValue a default value for the option. * @return this builder instance * @since 1.0.RC1 */ public Builder valueOptionalWithDefault(String defaultValue) { return valueOptionalWithDefault("", defaultValue); }
public ApplicationMetadata build() { checkNameDuplicates(application.options); return application; }
public Builder shortName(String shortName) { option.shortName = validateShortName(shortName); return this; }
protected Builder() { this.option = new OptionMetadata(); this.option.valueCardinality = OptionValueCardinality.NONE; }
public Builder name(String name) { command.name = validateName(name); return this; }
public OptionMetadata build() { validateName(option.name); return option; }