commands

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

package commands provides the interfaces and structures to trigger and run shell commands.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArgCount = fmt.Errorf("wrong count of args provided")
	ErrArgValue = fmt.Errorf("provided argument value invalid")
)

Errors produced by this file.

View Source
var ErrDisabled = fmt.Errorf("the command is disabled due to an error")
View Source
var (
	ErrNoCmd = fmt.Errorf("cmd provided without a command configured; fix it")
)

Errors produced by this file.

Functions

This section is empty.

Types

type Action

type Action struct {
	// contains filtered or unexported fields
}

Action contains the exported methods for this package.

func New

func New(config *common.Config, commands []*Command) *Action

New configures the library.

func (*Action) Create

func (a *Action) Create()

Create initializes the library.

func (*Action) GetByHash

func (a *Action) GetByHash(hash string) *Command

GetByHash returns a command by the hash ID.

func (*Action) List

func (a *Action) List() []*cmdconfig.Config

List returns a list of active triggers that can be executed.

type Command

type Command struct {
	cmdconfig.Config
	// contains filtered or unexported fields
}

Command contains the input data for a defined command. It also contains some saved data about the command being run.

func (*Command) Run

func (c *Command) Run(input *common.ActionInput)

Run fires a custom command.

func (*Command) RunNow

func (c *Command) RunNow(ctx context.Context, input *common.ActionInput) (string, error)

RunNow runs the command immediately, waits for and returns the output.

func (*Command) Setup

func (c *Command) Setup(logger mnd.Logger, website *website.Server)

Setup must run in the creation routine.

func (*Command) SetupRegexpArgs added in v0.4.1

func (c *Command) SetupRegexpArgs() error

func (*Command) Stats

func (c *Command) Stats() Stats

Stats returns statistics about a command.

type Stats

type Stats struct {
	Args       []*regexp.Regexp `json:"-"`
	Command    string           `json:"-"`
	Runs       int              `json:"runs"`
	Fails      int              `json:"fails"`
	LastOutput string           `json:"output"`
	LastRun    string           `json:"last"`
	LastArgs   []string         `json:"lastArgs"`
}

Stats for a command's invocations.

Directories

Path Synopsis
cmdconfig contains the input config for commands.
cmdconfig contains the input config for commands.

Jump to

Keyboard shortcuts

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