Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ICommandOptionDefinition

Used on a command definition to define option flags.

Hierarchy

  • ICommandOptionDefinition

Index

Properties

Optional absenceImplications

absenceImplications: string[]

Not specifying these options implies that you should specify all options listed in "absenceImplications".

e.g. if the user does not specify "vacation" then they must specify --job and --hours

memberof

ICommandOptionDefinition

Optional aliases

aliases: string[]

Aliases for your option. These allow the user to specify the option with a shorter or otherwise alternate name e.g. name: "puppy", aliases: ["p", "pup"] - the user can specify --puppy, -p, or --pup

memberof

ICommandOptionDefinition

Optional allowableValues

What values can be specified for this option? See the type below for more details.

memberof

ICommandOptionDefinition

Optional arrayAllowDuplicate

arrayAllowDuplicate: boolean

If the type is array, this option defines if duplicate values in array are allowed. Default is true.

memberof

ICommandOptionDefinition

Optional conflictsWith

conflictsWith: string[]

Defines which options this one conflicts with.

example
A and B can't be specified together const def: ICommandOptionDefinition = { name: "B", description conflictsWith: ["A"] }
memberof

ICommandOptionDefinition

Optional defaultValue

defaultValue: any

If the user doesn't specify this option, you can specify a default value here that will be filled in automatically.

memberof

ICommandOptionDefinition

description

description: string

The description of your option - displayed in the help text for your command.

memberof

ICommandOptionDefinition

Optional group

group: string

The group/category for this option. Options with the same group on the same command are grouped together under a heading with this text.

memberof

ICommandOptionDefinition

Optional hidden

hidden: boolean

Option is hidden from help

memberof

ICommandOptionDefinition

Optional implies

implies: string[]

If this option is specified, all options whose name appear in the "implies" field must also be specified. e.g. if this option is "vacation", and ["seat", "meal"] is the value for "implies", then the user will get a syntax error if they specify --vacation but not --seat and --meal

memberof

ICommandOptionDefinition

Optional impliesOneOf

impliesOneOf: string[]

If this option is specified, at least one of the options whose name appear in the "impliesOneOf" field must also be specified. e.g. if this option is "vacation", and ["seat", "meal"] is the value for "impliesOneOf", then the user will get a syntax error if they specify --vacation but not either --seat or --meal

memberof

ICommandOptionDefinition

name

name: string

The canonical/primary name for your option. This is the first form of the option shown to the user and is generally how you should refer to your option in documentation and programmatically.

Note: yargs automatically places the values for --hyphenated-options in a camelCase format after parsing the command line arguments, so you would be able to access params.arguments.hyphenatedOptions from your handler as well as params.arguments["hyphenated-options"]'

memberof

ICommandOptionDefinition

Optional numericValueRange

numericValueRange: [number, number]

Acceptable value range for number type options. the first number is the minimum. the second is the maximum So the value specified by the user must be min <= value <= max

memberof

ICommandOptionDefinition

Optional required

required: boolean

Is this option required? If it's required and the user does not specify it, they will get a syntax error.

Note: if you give a defaultValue to an option, it will always be considered to have been specified.

memberof

ICommandOptionDefinition

Optional stringLengthRange

stringLengthRange: [number, number]

Acceptable length range for string type options. the first number is the minimum. the second is the maximum So the length specified by the user must be min <= length <= max

memberof

ICommandOptionDefinition

type

What type of value will the user specify for this option?

memberof

ICommandOptionDefinition

Optional valueImplications

valueImplications: {}

If the user specifies a certain value for this option, then they must also specify other options (similar to a conditional "implies")

memberof

ICommandOptionDefinition

Type declaration

Generated using TypeDoc