command

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 7 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 Parameter

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

Parameter represents the Command Parameter

Directories

Path Synopsis
sql

Jump to

Keyboard shortcuts

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