shared

package
v0.1.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnrecognizedArgID is the error used when an Arg from the user data file
	// uses an unrecognized ID.
	ErrUnrecognizedArgID = errors.New(
		"Error with the ID of an argument: unrecognized ID",
	)

	// ErrUnrecognizedWritingMode is the error used when the mode inserted by the user
	// (on the action `WriteTextFile`) is out of the list of modes.
	ErrUnrecognizedWritingMode = errors.New(
		"Error with the writing mode: unrecognized mode",
	)

	// ErrEmptyCRResult is the error used when the field `ChainedResult.Result` is empty.
	ErrEmptyCRResult = errors.New(
		"Data from received chained result empty",
	)
	// ErrEmptyCRResultType is the error used when the field `ChainedResult.ResultType` is empty.
	ErrEmptyCRResultType = errors.New(
		"The type of the chained result is empty",
	)
	// ErrEmptyArgToReplace is the error that represents an empty `UserAction.ArgumentToReplaceByCR` field.
	ErrEmptyArgToReplace = errors.New(
		"The argument to replace by the ChainedResult is empty",
	)
	// ErrCRTypeDiffers represents an incompatibility between a ChainedResult and an action argument.
	ErrCRTypeDiffers = errors.New(
		"The type of the arg is not compatible with the ChainedResult",
	)

	// ErrWrongUVFormat is the error that represents an incorrect format on the name of a user variable.
	ErrWrongUVFormat = errors.New(
		"The format of the user variable is incorrect",
	)
)

Functions

func HandleCR

func HandleCR(userAction *data.UserAction, actionArgs []Arg, cr *ChainedResult) error

HandleCR checks if the usage of the `ChainedResult` it's enabled and, if it is, the content of the argument chained will be replaced with the content of the `ChainedResult`.

Types

type Action

type Action struct {
	ID                             string                                                                                                                `json:"ID"`
	Name                           string                                                                                                                `json:"name"`
	Description                    string                                                                                                                `json:"description"`
	Run                            func(previousResult *ChainedResult, parentAction *data.UserAction, parentTaskID string) (bool, *ChainedResult, error) `json:"-"`
	ReturnedChainResultDescription string                                                                                                                `json:"returnedChainResultDescription"`
	ReturnedChainResultType        types.PWType                                                                                                          `json:"returnedChainResultType"`
	Args                           []Arg                                                                                                                 `json:"args"`
}

Action represents an action of a task. Each task can have multiple actions and they will be executed according to the order given by the user (see data.UserAction.Order).

type Arg

type Arg struct {
	ID          string       `json:"ID"`
	Name        string       `json:"name"`
	Description string       `json:"description"`
	ContentType types.PWType `json:"contentType"`
}

Arg is the struct that defines each argument received by an Action.

type ChainedResult

type ChainedResult struct {
	Result     string
	ResultType types.PWType
}

ChainedResult is the struct used to communicate each consecutive action.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL