@nomiclabs/buidler > SimpleTaskDefinition

Class: SimpleTaskDefinition

This class creates a task definition, which consists of:

  • a name, that should be unique and will be used to call the task.
  • a description. This is optional.
  • the action that the task will execute.
  • a set of parameters that can be used by the action.

Hierarchy

SimpleTaskDefinition

Implements

Index

Constructors

Properties

Accessors

Methods


Constructors

constructor

new SimpleTaskDefinition(name: string, isInternal?: boolean): SimpleTaskDefinition

Defined in internal/core/tasks/task-definitions.ts:32

Creates an empty task definition.

This definition will have no params, and will throw a BDLR205 if executed.

Parameters:

Name Type Default value Description
name string - The task's name.
Default value isInternal boolean false `true` if the task is internal, `false` otherwise.

Returns: SimpleTaskDefinition


Properties

action

● action: ActionType<TaskArguments>

Implementation of TaskDefinition.action

Defined in internal/core/tasks/task-definitions.ts:27


isInternal

● isInternal: boolean

Implementation of TaskDefinition.isInternal

Defined in internal/core/tasks/task-definitions.ts:44

true if the task is internal, false otherwise.


name

● name: string

Implementation of TaskDefinition.name

Defined in internal/core/tasks/task-definitions.ts:43

The task's name.


paramDefinitions

● paramDefinitions: ParamDefinitionsMap

Implementation of TaskDefinition.paramDefinitions

Defined in internal/core/tasks/task-definitions.ts:25


positionalParamDefinitions

● positionalParamDefinitions: Array<ParamDefinition<any>> = []

Implementation of TaskDefinition.positionalParamDefinitions

Defined in internal/core/tasks/task-definitions.ts:26


Accessors

description

get description(): undefined | string

Defined in internal/core/tasks/task-definitions.ts:22

Returns: undefined | string


Methods

_addPositionalParamDefinition

_addPositionalParamDefinition(definition: ParamDefinition<any>): void

Defined in internal/core/tasks/task-definitions.ts:394

Adds a positional paramater to the task's definition.

Parameters:

Name Type Description
definition ParamDefinition<any> the param's definition

Returns: void


_hasParamDefined

_hasParamDefined(name: string): boolean

Defined in internal/core/tasks/task-definitions.ts:451

Checks if the given name is already used.

Parameters:

Name Type Description
name string the param's name.

Returns: boolean


_validateNameNotUsed

_validateNameNotUsed(name: string): void

Defined in internal/core/tasks/task-definitions.ts:428

Validates if the param's name is already used.

throws: BDLR201 if name is already used as a param.

throws: BDLR202 if name is already used as a param by Buidler

Parameters:

Name Type Description
name string the param's name.

Returns: void


_validateNoMandatoryParamAfterOptionalOnes

_validateNoMandatoryParamAfterOptionalOnes(name: string, isOptional: boolean): void

Defined in internal/core/tasks/task-definitions.ts:466

Validates if a mandatory param is being added after optional params.

throws: BDLR203 if validation fail

Parameters:

Name Type Description
name string the param's name to be added.
isOptional boolean true if the new param is optional, false otherwise.

Returns: void


_validateNotAfterVariadicParam

_validateNotAfterVariadicParam(name: string): void

Defined in internal/core/tasks/task-definitions.ts:412

Validates if the given param's name is after a variadic parameter.

throws: BDLR200

Parameters:

Name Type Description
name string the param's name.

Returns: void


addFlag

addFlag(name: string, description?: undefined | string): this

Implementation of TaskDefinition.addFlag

Defined in internal/core/tasks/task-definitions.ts:174

Adds a boolean paramater or flag to the task's definition.

Flags are params with default value set to false, and that don't expect values to be set in the CLI. A normal boolean param must be called with --param true, while a flag is called with --flag.

Parameters:

Name Type Description
name string the parameter's name.
Optional description undefined | string the parameter's description.

Returns: this


addOptionalParam

addOptionalParam<T>(name: string, description?: undefined | string, defaultValue?: T, type?: types.ArgumentType<T>): this

Implementation of TaskDefinition.addOptionalParam

Defined in internal/core/tasks/task-definitions.ts:155

Adds an optional paramater to the task's definition.

see: addParam.

Type parameters:

T

Parameters:

Name Type Description
name string the parameter's name.
Optional description undefined | string the parameter's description.
Optional defaultValue T a default value.
Optional type types.ArgumentType<T> param's type.

Returns: this


addOptionalPositionalParam

addOptionalPositionalParam<T>(name: string, description?: undefined | string, defaultValue?: T, type?: types.ArgumentType<T>): this

Implementation of TaskDefinition.addOptionalPositionalParam

Defined in internal/core/tasks/task-definitions.ts:278

Adds an optional positional paramater to the task's definition.

see: addPositionalParam.

Type parameters:

T

Parameters:

Name Type Description
name string the parameter's name.
Optional description undefined | string the parameter's description.
Optional defaultValue T a default value.
Optional type types.ArgumentType<T> param's type.

Returns: this


addOptionalVariadicPositionalParam

addOptionalVariadicPositionalParam<T>(name: string, description?: undefined | string, defaultValue?: T[] | T, type?: types.ArgumentType<T>): this

Defined in internal/core/tasks/task-definitions.ts:374

Adds a positional paramater to the task's definition.

This will check if the name is already used and if the parameter is being added after a varidic argument.

Type parameters:

T

Parameters:

Name Type Description
name string the parameter's name.
Optional description undefined | string the parameter's description.
Optional defaultValue T[] | T a default value.
Optional type types.ArgumentType<T> param's type.

Returns: this


addParam

addParam<T>(name: string, description?: undefined | string, defaultValue?: T, type?: types.ArgumentType<T>, isOptional?: boolean): this

Defined in internal/core/tasks/task-definitions.ts:87

Adds a paramater to the task's definition.

remarks: This will throw if the name is already used by this task or by Buidler's global parameters.

Type parameters:

T

Parameters:

Name Type Default value Description
name string - The parameter's name.
Optional description undefined | string - The parameter's description.
Optional defaultValue T - A default value. This must be `undefined` if `isOptional` is `true`.
Optional type types.ArgumentType<T> - The param's `ArgumentType`. It will parse and validate the user's input.
Default value isOptional boolean defaultValue !== undefined `true` if the parameter is optional. It's default value is `true` if `defaultValue` is not `undefined`.

Returns: this


addPositionalParam

addPositionalParam<T>(name: string, description?: undefined | string, defaultValue?: T, type?: types.ArgumentType<T>, isOptional?: boolean): this

Defined in internal/core/tasks/task-definitions.ts:206

Adds a positional paramater to the task's definition.

remarks: This will throw if the name is already used by this task or by Buidler's global parameters.

remarks: This will throw if isOptional is false and an optional positional param was already set.

remarks: This will throw if a variadic positional param is already set.

Type parameters:

T

Parameters:

Name Type Default value Description
name string - The parameter's name.
Optional description undefined | string - The parameter's description.
Optional defaultValue T - A default value. This must be `undefined` if `isOptional` is `true`.
Optional type types.ArgumentType<T> - The param's `ArgumentType`. It will parse and validate the user's input.
Default value isOptional boolean defaultValue !== undefined `true` if the parameter is optional. It's default value is `true` if `defaultValue` is not `undefined`.

Returns: this


addVariadicPositionalParam

addVariadicPositionalParam<T>(name: string, description?: undefined | string, defaultValue?: T[] | T, type?: types.ArgumentType<T>, isOptional?: boolean): this

Defined in internal/core/tasks/task-definitions.ts:297

Adds a variadic positional paramater to the task's definition. Variadic positional params act as ...rest parameters in JavaScript.

Type parameters:

T

Parameters:

Name Type Default value Description
name string - The parameter's name.
Optional description undefined | string - The parameter's description.
Optional defaultValue T[] | T - A default value. This must be `undefined` if `isOptional` is `true`.
Optional type types.ArgumentType<T> - The param's `ArgumentType`. It will parse and validate the user's input.
Default value isOptional boolean defaultValue !== undefined `true` if the parameter is optional. It's default value is `true` if `defaultValue` is not `undefined`.

Returns: this


setAction

setAction<ArgsT>(action: ActionType<ArgsT>): this

Implementation of TaskDefinition.setAction

Defined in internal/core/tasks/task-definitions.ts:69

Sets the task's action.

Type parameters:

ArgsT : TaskArguments

Parameters:

Name Type Description
action ActionType<ArgsT> The action.

Returns: this


setDescription

setDescription(description: string): this

Implementation of TaskDefinition.setDescription

Defined in internal/core/tasks/task-definitions.ts:60

Sets the task's description.

Parameters:

Name Type Description
description string The description.

Returns: this