可选价值

选项要么必须,要么不需要,通常其行为取决于指挥目标。spring-doc.cadn.net.cn

让选择权变得可选项。spring-doc.cadn.net.cn

CommandRegistration optionalOption() {
	return CommandRegistration.builder()
		.command("optionalOption")
		.withOption()
			.longNames("arg")
			.required(false)
			.and()
		.build();
}
void optionalOption(
	@Option(required = false) String arg
) {
}
void optionalOption(
	@ShellOption(defaultValue = ShellOption.NULL) String arg
) {
}

让选项成为强制性。spring-doc.cadn.net.cn

CommandRegistration mandatoryOption() {
	return CommandRegistration.builder()
		.command("optionalOption")
		.withOption()
			.longNames("arg")
			.required()
			.and()
		.build();
}
void mandatoryOption(
	@Option(required = true) String arg
) {
}
void mandatoryOption(
	@ShellOption() String arg
) {
}