@flowscripter/dynamic-cli-framework
    Preparing search index...

    Interface Positional

    Interface for SubCommand positional arguments.

    interface Positional {
        allowableValues?: readonly SingleValueType[];
        configurationKey?: string;
        description?: string;
        isCaseInsensitive?: boolean;
        isVarargMultiple?: boolean;
        isVarargOptional?: boolean;
        maxValueInclusive?: number;
        minValueInclusive?: number;
        name: string;
        type: ValueTypeName;
        validate?: (
            value: ValueType | Values | Values[],
            context: ValidationContext,
        ) => string | undefined;
    }

    Hierarchy (View Summary)

    Index
    allowableValues?: readonly SingleValueType[]

    Optional list of values that the value must match. This is not supported for ValueTypeName.BOOLEAN.

    configurationKey?: string

    Optional configuration key to use for the argument. Must consist of alphanumeric non-whitespace uppercase ASCII or _ characters. Must not start with a digit.

    If not specified a default configuration key is determined as follows: The SubCommandArgument.name is capitalized and any - characters are replaced with _ characters. If the result starts with a digit, it is prefixed with _. Some examples:

    • name: FooBar => configuration key: FOOBAR
    • name: Hello-World- => configuration key: HELLO_WORLD_
    • name: 3 => configuration key: _3

    NOTE: Regardless of whether a configurationKey is specified, or the default is relied upon, it will only be used if the parent Command has specified Command.enableConfiguration as true.

    description?: string

    Optional description of the argument.

    isCaseInsensitive?: boolean

    Optional (default is false) for ValueTypeName.STRING when comparing a value against allowableValues.

    isVarargMultiple?: boolean

    If this is true the argument can be specified one or multiple times and all values will be returned in an array matching the order provided.

    NOTE: If isVarargOptional is true, the argument can specified zero, one or multiple times.

    NOTE: There can be only one positional with this set and it must be the last the last item if there are multiple positionals defined.

    isVarargOptional?: boolean

    If this is true the argument can be specified zero or once i.e. it does not need to be specified.

    NOTE: If isVarargMultiple is true, the argument can specified zero, one or multiple times.

    NOTE: There can be only one positional with this set and it must be the last the last item if there are multiple positionals defined.

    maxValueInclusive?: number

    Optional for ValueTypeName.INTEGER or ValueTypeName.NUMBER when validating a value.

    minValueInclusive?: number

    Optional for ValueTypeName.INTEGER or ValueTypeName.NUMBER when validating a value.

    name: string

    Name of the argument.

    Must consist of alphanumeric non-whitespace ASCII or _ and - characters. Cannot start with -.

    Type of the argument value.

    validate?: (
        value: ValueType | Values | Values[],
        context: ValidationContext,
    ) => string | undefined

    Optional custom validation function invoked after all built-in validation has passed. Receives the validated and type-converted value and a ValidationContext giving access to all other provided values of the command. A validator that only needs the value may declare just the first parameter.

    Return undefined if the value is valid, or a string describing the validation error. The error string is associated with InvalidArgumentReason.CUSTOM_VALIDATION.

    Validators declared on properties nested inside ComplexOption.properties are also invoked, at any depth:

    • Validation is bottom-up and depth-first, in properties declaration order. A property's validator is invoked after the validators of its own child properties, and only if they all passed. A parent therefore always receives a fully converted and child-validated value.
    • Validation stops at the first failure, so later validators are not invoked.
    • For an argument with isArray, the validator is invoked once with the whole converted array. For an array of ComplexOption values, the child property validators are invoked for each element.
    • An absent nested property with a defaultValue is validated using the default value. An absent nested property with isOptional and no default is skipped and its validator is not invoked.
    • A nested failure is reported with the full property path as the invalid argument name, e.g. opt.sub[2].field.

    Example: ensure array values are unique:

    validate: (value) => {
    const arr = value as string[];
    return new Set(arr).size !== arr.length
    ? "values must be unique"
    : undefined;
    }