Label

Option Label 在 Shell 本身內沒有功能性行為,除了預設的 help 命令輸出之外。在命令文件中,選項的類型會被記錄,但這並不總是超級有用。因此,您可能想要為選項提供更好的描述性詞語。

legacy annotation 不支援 Label。
  • Programmatic

  • Annotation

CommandRegistration labelOption() {
	return CommandRegistration.builder()
		.withOption()
			.longNames("arg")
			.label("MYLABEL")
			.and()
		.build();
}
void labelOption(
	@Option(label = "MYLABEL") String arg
) {
}

定義標籤隨後會顯示在 help 中。

my-shell:>help labelOption
NAME
       labelOption -

SYNOPSIS
       labelOption --arg MYLABEL

OPTIONS
       --arg MYLABEL
       [Optional]