Skip to main content

Class: Massarg<Args>

massarg.Massarg

This class behaves similarly to MassargCommand, but it accepts only params that are relevant to the top-level command.

See

Type parameters

NameType
Argsextends ArgsObject = ArgsObject

Hierarchy

Constructors

constructor

new Massarg<Args>(options): Massarg<Args>

Type parameters

NameType
Argsextends ArgsObject = ArgsObject

Parameters

NameType
optionsMinimalCommandConfig<Args>

Returns

Massarg<Args>

Overrides

MassargCommand.constructor

Defined in

src/massarg.ts:20

Properties

name

name: string

Inherited from

MassargCommand.name

Defined in

src/command.ts:79


description

description: string

Inherited from

MassargCommand.description

Defined in

src/command.ts:80


aliases

aliases: string[]

Inherited from

MassargCommand.aliases

Defined in

src/command.ts:81


commands

commands: MassargCommand<any>[] = []

Inherited from

MassargCommand.commands

Defined in

src/command.ts:83


options

options: MassargOption<unknown, ArgsObject>[] = []

Inherited from

MassargCommand.options

Defined in

src/command.ts:84


examples

examples: MassargExample[] = []

Inherited from

MassargCommand.examples

Defined in

src/command.ts:85


args

args: Partial<Args> = {}

Inherited from

MassargCommand.args

Defined in

src/command.ts:86


parent

Optional parent: MassargCommand<any>

Inherited from

MassargCommand.parent

Defined in

src/command.ts:89


optionPrefix

optionPrefix: string = DEFAULT_OPT_FULL_PREFIX

Inherited from

MassargCommand.optionPrefix

Defined in

src/command.ts:90


aliasPrefix

aliasPrefix: string = DEFAULT_OPT_SHORT_PREFIX

Inherited from

MassargCommand.aliasPrefix

Defined in

src/command.ts:91

Accessors

optionPrefixes

get optionPrefixes(): Prefixes

Returns

Prefixes

Inherited from

MassargCommand.optionPrefixes

Defined in

src/command.ts:106


helpConfig

get helpConfig(): DeepRequired<{ bindCommand?: boolean ; bindOption?: boolean ; useGlobalTableColumns?: boolean ; commandOptions?: { compact?: boolean ; nameStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; descriptionStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; namePrefix?: string ; aliasPrefix?: string } ; optionOptions?: { compact?: boolean ; nameStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; descriptionStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; namePrefix?: string ; aliasPrefix?: string ; displayNegations?: boolean ; displayDefaultValue?: boolean ; defaultValueStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } } ; titleStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; descriptionStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; subtitleStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; usageStyle?: { prefix?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; main?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; command?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; options?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } } ; headerStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; footerStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; lineLength?: number ; exampleOptions?: { descriptionStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; inputStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; outputStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; inputPrefix?: string ; outputPrefix?: string ; prefixStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; compact?: boolean } ; usageText?: string ; headerText?: string ; footerText?: string }>

Returns

DeepRequired<{ bindCommand?: boolean ; bindOption?: boolean ; useGlobalTableColumns?: boolean ; commandOptions?: { compact?: boolean ; nameStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; descriptionStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; namePrefix?: string ; aliasPrefix?: string } ; optionOptions?: { compact?: boolean ; nameStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; descriptionStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; namePrefix?: string ; aliasPrefix?: string ; displayNegations?: boolean ; displayDefaultValue?: boolean ; defaultValueStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } } ; titleStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; descriptionStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; subtitleStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; usageStyle?: { prefix?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; main?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; command?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; options?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } } ; headerStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; footerStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; lineLength?: number ; exampleOptions?: { descriptionStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; inputStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; outputStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; inputPrefix?: string ; outputPrefix?: string ; prefixStyle?: { bold?: boolean ; underline?: boolean ; color?: $InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }> ; reset?: boolean } ; compact?: boolean } ; usageText?: string ; headerText?: string ; footerText?: string }>

Inherited from

MassargCommand.helpConfig

Defined in

src/command.ts:113

Methods

command

command<A>(config): MassargCommand<Args & A>

Add a sub-command to this command.

The sub-command will inherit all help configuration from the parent commands, all the way up to the top-level command.

While options are not inherited, they will be passed from any parent commands to the sub-command when invoked.

Type parameters

NameType
Aextends ArgsObject = Args

Parameters

NameTypeDescription
configObject-
config.namestringCommand name
config.descriptionstringCommand description, displayed in the help output
config.runRunner<A>Function used when invoking this command. It receives the parsed options and the primary instance of Massarg used to invoke this command (the top-level instance)
config.aliases?string[]Command aliases
config.optionPrefix?stringThe prefix to match before option names, e.g. --
config.aliasPrefix?stringThe prefix to match before option aliases, e.g. -

Returns

MassargCommand<Args & A>

Inherited from

MassargCommand.command

Defined in

src/command.ts:140

command<A>(config): MassargCommand<Args & A>

Type parameters

NameType
Aextends ArgsObject = Args

Parameters

NameType
configMassargCommand<A>

Returns

MassargCommand<Args & A>

Inherited from

MassargCommand.command

Defined in

src/command.ts:141


flag

flag(config): MassargCommand<Args>

Adds a flag to this command.

A flag is an option that is either present or not. It can be used to toggle a boolean value, or to indicate that a command should be run in a different mode.

A flag can be negated by using negatable: true. By default, the negated name is the same as the option name, prefixed by no-, and each of the aliases will be uppercased. For example, --verbose and --no-verbose, or -v and -V. This behavior can be overridden by the negatedName and negatedAliases options.

Parameters

NameTypeDescription
configObject-
config.namestringName of the option
config.descriptionstringDescription of the option, displayed in the help output
config.aliasesstring[]Aliases for the option, which can be used with the shorthand option notation.
config.defaultValue?anyDefault value of the option
config.array?booleanWhether the option is an array. Array options can be specified multiple times, and the values will be collected into an array. Normally, specifying an option multiple times will override the previous value.
config.required?booleanWhether the option is required. If it is required, parsing will throw an error if it's not present.
config.hidden?booleanWhether the option is hidden. Hidden options are not displayed in the help output.
config.outputName?stringSpecify a custom name for the output, which will be used when parsing the args.
config.negatable?booleanWhether the flag can be negated, e.g. --no-verbose
config.negationName?stringNegation name of the option, which can be used with the full option notation. Defaults to no-{name} of your option's name, e.g. verbose becomes --no-verbose. To use this, you must set negatable: true in the option's configuration.
config.negationAliases?string[]Negation aliases for the option, which can be used with the shorthand option notation. Defaults to uppercase of each of the aliases provided, e.g. q becomes -Q. To use this, you must set negatable: true in the option's configuration.

Returns

MassargCommand<Args>

Inherited from

MassargCommand.flag

Defined in

src/command.ts:183

flag(config): MassargCommand<Args>

Parameters

NameType
configMassargFlag

Returns

MassargCommand<Args>

Inherited from

MassargCommand.flag

Defined in

src/command.ts:184


option

option<T, A>(config): MassargCommand<Args>

Adds an option to this command.

An option is a named value that can be passed to a command. It can be required or optional, and can be of any type.

You can specify a default value for an option, which will be used if the option is not passed to the command.

You can also specify a parse function, which will be used to parse the value passed to the command. This is useful if you want to parse a string into a more complex type, or if you want to validate the value.

Type parameters

NameType
Tstring
Aextends ArgsObject = Args

Parameters

NameType
configMassargOption<T, A>

Returns

MassargCommand<Args>

Inherited from

MassargCommand.option

Defined in

src/command.ts:217

option<T, A>(config): MassargCommand<Args>

Type parameters

NameType
Tstring
Aextends ArgsObject = Args

Parameters

NameTypeDescription
configObject-
config.namestringName of the option
config.descriptionstringDescription of the option, displayed in the help output
config.aliasesstring[]Aliases for the option, which can be used with the shorthand option notation.
config.defaultValue?anyDefault value of the option
config.parse?Parser<A, T>Parse the value of the option. You can return any type here, or throw an error if the value is invalid.
config.array?booleanWhether the option is an array. Array options can be specified multiple times, and the values will be collected into an array. Normally, specifying an option multiple times will override the previous value.
config.required?booleanWhether the option is required. If it is required, parsing will throw an error if it's not present.
config.isDefault?booleanWhether the option is the default option. The default option is the option that is used if no other option is specified, e.g. a value is passed in without an option name. Note that if commands match the same argument first, they will be used instead of the default option.
config.hidden?booleanWhether the option is hidden. Hidden options are not displayed in the help output.
config.outputName?stringSpecify a custom name for the output, which will be used when parsing the args.
config.type?"number"-

Returns

MassargCommand<Args>

Inherited from

MassargCommand.option

Defined in

src/command.ts:218


example

example(config): MassargCommand<Args>

Adds an example to this command.

An example is a description of how to use the command, with an example input and output.

At least one of description, input or output must be provided, but neither alone is required.

Parameters

NameTypeDescription
configObject-
config.description?stringDescription of the example. This will appear as a title above the input/output line(s).
config.input?stringInput of the example. This will appear as a line below the description, with a $ prefix. The prefix can be changed using the help() function on the command.
config.output?stringOutput of the example. This will appear as a line below the input, with a > prefix. The prefix can be changed using the help() function on the command.

Returns

MassargCommand<Args>

Inherited from

MassargCommand.example

Defined in

src/command.ts:294


help

help(config): MassargCommand<Args>

Configure the help output for this (and all child) commands.

You can automatically bind the help command to this command, and/or bind the help option to this command.

If you don't opt-in to this behavior with bindCommand or bindOption, you can still access the help output via this.helpString() and this.printHelp().

Parameters

NameTypeDescription
configObject-
config.bindCommand?booleanWhether to bind the help command to this command Set this to true to automatically add a help command to this command's subcommands.
config.bindOption?booleanWhether to bind the help option to this command Set this to true to automatically add a --help option to this command's options.
config.useGlobalTableColumns?booleanWhether to align all tables to the column widths, or have each table be independent. Default is true
config.commandOptions?ObjectOptions for generating the table of commands
config.commandOptions.compact?booleanWhen false, each row is separated by a blank line
config.commandOptions.nameStyle?ObjectStyle of the command/option name
config.commandOptions.nameStyle.bold?boolean-
config.commandOptions.nameStyle.underline?boolean-
config.commandOptions.nameStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.commandOptions.nameStyle.reset?boolean-
config.commandOptions.descriptionStyle?ObjectStyle of the command/option description
config.commandOptions.descriptionStyle.bold?boolean-
config.commandOptions.descriptionStyle.underline?boolean-
config.commandOptions.descriptionStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.commandOptions.descriptionStyle.reset?boolean-
config.commandOptions.namePrefix?stringPrefix for the command/option name (default is the command's prefix)
config.commandOptions.aliasPrefix?stringPrefix for the command/option aliases (default is the command's prefix)
config.optionOptions?ObjectOptions for generating the table of options
config.optionOptions.compact?booleanWhen false, each row is separated by a blank line
config.optionOptions.nameStyle?ObjectStyle of the command/option name
config.optionOptions.nameStyle.bold?boolean-
config.optionOptions.nameStyle.underline?boolean-
config.optionOptions.nameStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.optionOptions.nameStyle.reset?boolean-
config.optionOptions.descriptionStyle?ObjectStyle of the command/option description
config.optionOptions.descriptionStyle.bold?boolean-
config.optionOptions.descriptionStyle.underline?boolean-
config.optionOptions.descriptionStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.optionOptions.descriptionStyle.reset?boolean-
config.optionOptions.namePrefix?stringPrefix for the command/option name (default is the command's prefix)
config.optionOptions.aliasPrefix?stringPrefix for the command/option aliases (default is the command's prefix)
config.optionOptions.displayNegations?booleanWhether to display negations with each option name
config.optionOptions.displayDefaultValue?booleanWhether to display the default value with each option (if it has one)
config.optionOptions.defaultValueStyle?ObjectStyle of the default value
config.optionOptions.defaultValueStyle.bold?boolean-
config.optionOptions.defaultValueStyle.underline?boolean-
config.optionOptions.defaultValueStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.optionOptions.defaultValueStyle.reset?boolean-
config.titleStyle?ObjectStyle of the help title
config.titleStyle.bold?boolean-
config.titleStyle.underline?boolean-
config.titleStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.titleStyle.reset?boolean-
config.descriptionStyle?ObjectStyle of the help description
config.descriptionStyle.bold?boolean-
config.descriptionStyle.underline?boolean-
config.descriptionStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.descriptionStyle.reset?boolean-
config.subtitleStyle?ObjectStyle of the help subtitles for commands, options and examples
config.subtitleStyle.bold?boolean-
config.subtitleStyle.underline?boolean-
config.subtitleStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.subtitleStyle.reset?boolean-
config.usageStyle?ObjectStyle of the help usage
config.usageStyle.prefix?ObjectStyle of the help usage title - appears before the usage text (custom or auto)
config.usageStyle.prefix.bold?boolean-
config.usageStyle.prefix.underline?boolean-
config.usageStyle.prefix.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.usageStyle.prefix.reset?boolean-
config.usageStyle.main?ObjectFor custom usage text, this is the primary style used (right after the prefix style). For automated usage text, this style is used for the command/binary name
config.usageStyle.main.bold?boolean-
config.usageStyle.main.underline?boolean-
config.usageStyle.main.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.usageStyle.main.reset?boolean-
config.usageStyle.command?ObjectStyle of the help usage commands (if any)
config.usageStyle.command.bold?boolean-
config.usageStyle.command.underline?boolean-
config.usageStyle.command.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.usageStyle.command.reset?boolean-
config.usageStyle.options?ObjectStyle of the help usage options (if any)
config.usageStyle.options.bold?boolean-
config.usageStyle.options.underline?boolean-
config.usageStyle.options.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.usageStyle.options.reset?boolean-
config.headerStyle?ObjectStyle of the help header
config.headerStyle.bold?boolean-
config.headerStyle.underline?boolean-
config.headerStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.headerStyle.reset?boolean-
config.footerStyle?ObjectStyle of the help footer
config.footerStyle.bold?boolean-
config.footerStyle.underline?boolean-
config.footerStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.footerStyle.reset?boolean-
config.lineLength?numberMaximum length of a row in the help output
config.exampleOptions?ObjectOptions for examples section
config.exampleOptions.descriptionStyle?ObjectStyle of the example description
config.exampleOptions.descriptionStyle.bold?boolean-
config.exampleOptions.descriptionStyle.underline?boolean-
config.exampleOptions.descriptionStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.exampleOptions.descriptionStyle.reset?boolean-
config.exampleOptions.inputStyle?ObjectStyle of the example input
config.exampleOptions.inputStyle.bold?boolean-
config.exampleOptions.inputStyle.underline?boolean-
config.exampleOptions.inputStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.exampleOptions.inputStyle.reset?boolean-
config.exampleOptions.outputStyle?ObjectStyle of the example output
config.exampleOptions.outputStyle.bold?boolean-
config.exampleOptions.outputStyle.underline?boolean-
config.exampleOptions.outputStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.exampleOptions.outputStyle.reset?boolean-
config.exampleOptions.inputPrefix?stringPrefix for the example input (default: $)
config.exampleOptions.outputPrefix?stringPrefix for the example output (default: >)
config.exampleOptions.prefixStyle?ObjectStyle of the example input/output prefixes
config.exampleOptions.prefixStyle.bold?boolean-
config.exampleOptions.prefixStyle.underline?boolean-
config.exampleOptions.prefixStyle.color?$InferEnumOutput<{ red: "red" ; green: "green" ; yellow: "yellow" ; blue: "blue" ; magenta: "magenta" ; cyan: "cyan" ; white: "white" ; gray: "gray" ; grey: "grey" ; brightRed: "brightRed" ; brightGreen: "brightGreen" ; brightYellow: "brightYellow" ; brightBlue: "brightBlue" ; brightMagenta: "brightMagenta" ; brightCyan: "brightCyan" ; brightWhite: "brightWhite" }>-
config.exampleOptions.prefixStyle.reset?boolean-
config.exampleOptions.compact?booleanWhether to compact the examples section
config.usageText?stringText to display at the very top, describing CLI usage
config.headerText?stringText to display above the description, below the usage
config.footerText?stringText to display at the very bottom, below the examples

Returns

MassargCommand<Args>

Inherited from

MassargCommand.help

Defined in

src/command.ts:308


main

main(run): MassargCommand<Args>

Configure the main function for this command. This command will run when no sub-commands are provided.

If none is provided, help will be printed.

Parameters

NameType
runRunner<Args>

Returns

MassargCommand<Args>

Inherited from

MassargCommand.main

Defined in

src/command.ts:326


onError

onError(handler): MassargCommand<Args>

Configure a custom error handler for this command.

By default, errors are caught and logged to stderr with a red color. Use this method to override the default error handling behavior.

Note: The process will always exit with code 1 after an error, regardless of the handler.

Parameters

NameType
handlerErrorHandler

Returns

MassargCommand<Args>

Example

massarg(options)
.onError((error) => {
console.error('Custom error:', error.message)
// Log to external service, show custom UI, etc.
})
.parse()

Inherited from

MassargCommand.onError

Defined in

src/command.ts:349


parse

parse(argv?, args?, parent?): void | Promise<void>

Parse the given arguments and run the command or sub-commands along with the given options and flags.

To parse the arguments without running any commands and only get the output args, use getArgs instead.

Parameters

NameType
argvstring[]
args?Partial<Args>
parent?MassargCommand<Args>

Returns

void | Promise<void>

Inherited from

MassargCommand.parse

Defined in

src/command.ts:378


getArgs

getArgs(argv, __args?, parent?, parseCommands?): void | Promise<void>

Parse the given arguments and return the output args.

Parameters

NameType
argvstring[]
__args?Partial<Args>
parent?MassargCommand<any>
parseCommands?false

Returns

void | Promise<void>

Inherited from

MassargCommand.getArgs

Defined in

src/command.ts:433

getArgs(argv, __args?, parent?, parseCommands?): Args

Parameters

NameType
argvstring[]
__args?Partial<Args>
parent?MassargCommand<any>
parseCommands?true

Returns

Args

Inherited from

MassargCommand.getArgs

Defined in

src/command.ts:439


helpString

helpString(): string

Generate the help output for this command, and return it as a string.

Returns

string

Inherited from

MassargCommand.helpString

Defined in

src/command.ts:543


printHelp

printHelp(): void

Print the help output for this command.

Returns

void

Inherited from

MassargCommand.printHelp

Defined in

src/command.ts:550