Skip to content
Maytham edited this page Oct 2, 2021 · 3 revisions

Note: This page is incomplete. Contribute by adding information.

Option(flags[, description])

new Option(flags[, description])

Initialize a new Option with the given flags and description.

Parameters

  • flags, type string: The flags that can be used when calling the command. Same as Program.option().
  • description (optional), type string: The description that is used in the automated help page. Same as Program.option().

Methods

argParser([fn])

Set the custom handler for processing CLI option arguments into option values.

Parameters:

  • fn (optional), type function

attributeName()

Return option name, in a camelcase format that can be used as a object attribute key.

Returns:

  • string: The name of the option in camelcase format

choices(values)

Only allow option value to be one of choices.

Parameters:

  • values, type Array[string]: Array of choices allowed

Returns:

  • Option: The object itself for chaining

default(value[, description])

Set the default value, and optionally supply the description to be displayed in the help.

Parameters:

  • value, any type: The default value
  • description (optional), type string: The description that is shown on the help page

Returns:

  • Option: The object itself for chaining

env(name)

Set the environment variable that is used to check for an option value.