FlagOption

flitter-cli/options/FlagOption~ FlagOption

Non-positional, flag-based CLI option.


Constructor

new FlagOption(long_flag, short_flag, message, argument_description)

Instantiate the option.

Parameters:
Name Type Default Description
long_flag string | boolean false

the name of the long flag (e.g. '--long'), false to disable

short_flag string | boolean false

the name of the short flag (e.g. '-f'), false to disable

message string | boolean false

help message, false to disable

argument_description string | boolean false

argument description, false to disable

Extends

Members

(private) _blacklist :Array.<*>

Blacklisted values.

Type:
  • Array.<*>

(private) _equality_value :*

The value to be used to check equality.

Type:
  • *

(private) _greater_than_bit :boolean

If true, the greater than will be greater than or equal to.

Type:
  • boolean

(private) _greater_than_value :*

Value to be compared in greater than.

Type:
  • *

(private) _less_than_bit :boolean

If true, the less than will be less than or equal to.

Type:
  • boolean

(private) _less_than_value :*

Value to be compared in less than.

Type:
  • *

(private) _optional :boolean

Is this option optional?

Type:
  • boolean

(private) _use_blacklist :boolean

Do we use the blacklist?

Type:
  • boolean

(private) _use_equality :boolean

Do we use the equality operator?

Type:
  • boolean

(private) _use_greater_than :boolean

Do we use the greater-than comparison?

Type:
  • boolean

(private) _use_less_than :boolean

Do we use the less-than comparison?

Type:
  • boolean

(private) _use_whitelist :boolean

Do we use the whitelist?

Type:
  • boolean

(private) _whitelist :Array.<*>

Whitelisted values.

Type:
  • Array.<*>

argument_description :string|boolean

The argument description.

Type:
  • string | boolean

argument_name

Get the referential name for this option. Defaults to the long flag (without the '--'). If this cannot be found, the short flag (without the '-') is used.

long_flag :string|boolean

The long flag for this option. e.g. '--long'

Type:
  • string | boolean

message :string|boolean

The help message.

Type:
  • string | boolean

requirement_displays

Get an array of strings denoting the human-readable requirements for this option to be valid.

short_flag :string|boolean

The short flag for this option. e.g. '-l'

Type:
  • string | boolean

Methods

blacklist(…items)

Blacklist the specified item or items and enable the blacklist.

Parameters:
Name Type Attributes Description
items * <repeatable>

the items to blacklist

equals(value)

Specifies the value to be used in equality comparison and enables that comparison.

Parameters:
Name Type Description
value *

greater_than(value)

Specifies the value to be used in greater-than comparison and enables that comparison.

Parameters:
Name Type Description
value *

greater_than_equal_to(value)

Specifies the value to be used in greater-than or equal-to comparison and enables that comparison.

Parameters:
Name Type Description
value *

less_than(value)

Specifies the value to be used in less-than comparison and enables less-than comparison.

Parameters:
Name Type Description
value *

less_than_equal_to(value)

Specifies the value to be used in less-than or equal-to comparison and enables that comparison.

Parameters:
Name Type Description
value *

optional()

Sets the Option as optional.

validate(value) → {boolean}

Checks if the specified value passes the configured comparisons.

Parameters:
Name Type Description
value *
Returns:
Type
boolean

whitelist(…items)

Whitelist the specified item or items and enable the whitelist.

Parameters:
Name Type Attributes Description
items * <repeatable>

the items to whitelist