command

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidNumOfParams = errors.New("invalid number of params provided")

ErrInvalidNumOfParams returned when the number of params provided doesn't match the command

Functions

func WithParams

func WithParams(params []Parameter) cmdOpt

WithParams used to pass the params to the Command. Returns an error if the param is not found.

Types

type Argument

type Argument struct {
	Name  string
	Value string
}

Argument represents the command arguments to place in the params

type Command

type Command struct {
	ID          uuid.UUID
	Name        string
	Description string
	Command     string
	Params      []Parameter
}

Command represents a shell.

func New

func New(name string, desc string, rawCmd string, opts ...cmdOpt) (Command, error)

New returns a new Command.

func (*Command) Build

func (c *Command) Build() error

Build builds the internal attributes (template and params).

func (*Command) Compile

func (c *Command) Compile(args []Argument) (string, error)

Compile returns the command with the arguments applied.

type History added in v0.4.0

type History struct {
	Usages []Usage
}

History contains the history of usage of the command.

type Parameter

type Parameter struct {
	ID           uuid.UUID
	Name         string
	Description  string
	DefaultValue string
}

Parameter represents the Command Parameter

type Usage added in v0.4.0

type Usage struct {
	Command   string
	Timestamp time.Time
}

Usage holds the information of a particular usage of the command.

Directories

Path Synopsis
sql

Jump to

Keyboard shortcuts

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