Class Argument<T>Abstract

Type Parameters

  • T

Hierarchy

  • Argument

Constructors

  • Type Parameters

    • T

    Parameters

    • type: string
    • isMultiType: boolean = false

    Returns Argument<T>

Properties

_conflicts: string[] = []
_dependencies: string[] = []
_description: undefined | string
_exclusive: boolean = false
_isMultiType: boolean = false
_negated: boolean = false
_optional: boolean = false
_opts: ArgumentOpts = ...
_otherParsers: MinimalArgument<CoercedValue>[] = []
_requiredUnlessPresent: string[] = []
_specifiedDefault: undefined | T = undefined
_unspecifiedDefault: undefined | T = undefined
type: string

Accessors

Methods

  • Try to coerce a string value into the (T) type of this Argument.

    Generally an internal API but it is safe for public consumption, if you wish to compose the default coercion types with your own.

    Parameters

    • value: string

      the value to coerce

    Returns Promise<CoercionResult<T>>

  • Marks that this argument conflicts with another, meaning if this argument is given, the other must not be given.

    Returns

    this

    Parameters

    • arg: `--${string}`

      the argument which this argument conflicts with

    Returns Argument<T>

  • Sets the default value for when an argument is not specified in the arguments

    See

    Argument#presentDefault

    Returns

    this

    Parameters

    • arg: T

    Returns Omit<Argument<T>, "required">

  • Marks that this argument depends on another, meaning if this argument is given, the other must be given.

    Returns

    this

    Parameters

    • arg: `--${string}`

      the argument which this argument depends on

    Returns Argument<T>

  • Provide a description for this argument, for use in the help message.

    Returns

    this

    Parameters

    • description: string

      the description of this argument

    Returns Argument<T>

  • Parameters

    • passedValue: string
    • error: Error

    Returns CoercionResultErr

  • Marks this argument as exclusive, meaning no other arguments can be passed with it.

    Returns

    this

    Returns Omit<Argument<T>, "dependsOn" | "conflictsWith">

  • Inverts the negation status for this argument. Negation is handled independently (or not at all) by each argument type as it coerces a value.

    Returns

    this

    Returns Argument<T>

  • Parameters

    • passedValue: string
    • returnedValue: T

    Returns CoercionResultOk<T>

  • Marks this argument as optional, meaning it does not need a value, and does not need to be specified in the arguments.

    Returns

    this

    Returns Omit<Argument<undefined | T>, "default" | "required">

  • Configures a new options object for this argument. This will not deep copy the provided object, which may be mutated by subsequent calls on this object.

    Returns

    this

    Parameters

    Returns Argument<T>

  • Add another parser to this argument, enabling either argument to be used to coerce the value

    Returns

    this

    Type Parameters

    • U extends CoercedValue

    Parameters

    • other: Argument<U>

      the other parser to use

    Returns Omit<Argument<T | U>, "array">

  • Sets the default value for when an argument is specified in the arguments, but not given a value.

    See

    Argument#default

    Returns

    this

    Parameters

    • arg: T

    Returns Omit<Argument<T>, "required">

  • Mark this argument as required unless the specified argument is passed

    Returns

    this

    Parameters

    • arg: `--${string}`

      the argument which will be checked against

    Returns Argument<T>

  • Marks this argument as required, meaning it does need a value, and does need to be specified in the arguments.

    Returns

    this

    Returns Omit<Argument<NonNullable<T>>, "optional">

  • Parameters

    • specificity: "specified" | "unspecified"

    Returns Promise<undefined | T>

Generated using TypeDoc