Options

命令行参数可以分为选项和位置参数。以下章节描述了选项的定义和使用方式。我们首先介绍一些有关使用选项的基础知识,然后再详细介绍选项和参数的各种工作方式。

Command line arguments can be separated into options and positional parameters. Following sections describes features how options are defined and used. We first go through some basics about using options and then go into details about various ways how options and arguments works.

一般来说,option 是带有 --- 前缀的命令之后的某些内容。option 可以根据其上下文有值,也可以没有值。

Generally speaking an option is something after a commands prefixed with either - or --. An option can either have a value or not depending on its context.

可以使用带有方法参数的带注释的目标方法或使用 CommandRegistration 以编程方式来定义选项。

Options can be defined with a target method using annotations with a method arguments or with programmatically using CommandRegistration.

在以下各部分中,@ShellOption 指的是 legacy annotation model@Option 指的是 annotation model

In below sections @ShellOption refer to a legacy annotation model and @Option refer to an annotation model.