commands

commands

Source:

Parsing of commands and utilities.

Classes

Cancellable
CodeFormatter
Interpreter
MetaFormatter

Namespaces

validation

Type Definitions

Command(ctx, argsopt) → {object}

Source:
Properties:
Name Type Description
meta commands.Meta

Metadata about the command.

A function that implements a command.

Parameters:
Name Type Attributes Description
ctx object

Context to execute the command.

Properties
Name Type Attributes Description
ct commands.Cancellable

A cancellation token.

... object <optional>
<repeatable>

Extra context objects needed for the command, like the objects that the command manipulates.

args Array.<object> <optional>

The command arguments all packed in an array.

Returns:

Optionally the command can return any value. If meta.returns is set, the command must return a value that adheres to the meta.returns validation function.

Type
object

Meta

Source:
Properties:
Name Type Attributes Description
name string

Command name.

desc string

Command description.

params Array.<commands.Param>

Parameter specification for the command.

returns commands.Validate <optional>

Return "specification" of the command. This validation function is never actually called, but it's used to check if the "return" of a command adheres to the parameter validation function of another.

Metadata about a command.

Type:
  • object

Param

Source:
Properties:
Name Type Attributes Description
name string

Parameter name.

validate commands.Validate

Parameter validation function.

isRest boolean <optional>

If the parameter is a rest parameter, i.e, it accepts a variable number of arguments (1 or more). A rest parameter must be the last parameter of a command.

Command parameter specification.

Type:
  • object

Validate(arg) → {boolean}

Source:
Properties:
Name Type Attributes Description
exp string

The expected value for this validation function to succeed. Used in error messages.

type string

A representation of the "type" of value being validated.

base string

The base JavaScript type for the value: "string", "number", "boolean", etc.

min number <optional>

The minimum value allowed (for numbers).

max number <optional>

The maximum value allowed (for numbers).

options Array.<string> <optional>

The options allowed (like an enum).

A validation function for a command parameter. Can also be used to indicate the return "specification" of a command.

Parameters:
Name Type Description
arg object

Argument to validate.

Returns:

If the validation succeeds or not.

Type
boolean