griffin

package
v0.0.5-beta Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteExit

func ExecuteExit()

ExecuteExit TODO: define default actions custom properly

Types

type Action

type Action struct {
	Function      func()
	InputFunction func([]string)
}

func NewAction

func NewAction(function func()) *Action

func NewInputAction

func NewInputAction(function func([]string)) *Action

func (Action) Execute

func (a Action) Execute()

type Command

type Command struct {
	Id      string
	Args    int
	Pattern string
	*Action
	Description string
}

func (Command) Execute

func (c Command) Execute()

func (Command) ExecuteWith

func (c Command) ExecuteWith(args []string)

type CommandConfiguration

type CommandConfiguration struct {
	Id          string `yaml:"id"`
	Description string `yaml:"description"`
	Args        int    `yaml:"args"`
	Action      string `yaml:"action"`
	Pattern     string `yaml:"pattern"`
}

type CommandMap

type CommandMap struct {
	Commands map[string]*Command
}

func (*CommandMap) Lookup

func (m *CommandMap) Lookup(plan string) *Command

type CommandsConfiguration

type CommandsConfiguration struct {
	CommandList []CommandConfiguration `yaml:"commands"`
}

func LoadCommands

func LoadCommands(configFile string) *CommandsConfiguration

type ExecutionPlan

type ExecutionPlan struct {
	Plan    string
	Command *Command
}

func Prepare

func Prepare(plan string) *ExecutionPlan

func (*ExecutionPlan) Execute

func (e *ExecutionPlan) Execute()

func (*ExecutionPlan) With

func (e *ExecutionPlan) With(command *Command) *ExecutionPlan

type Shell

type Shell struct {
	Prompt             string
	Suggestions        []prompt.Suggest
	CommandMap         *CommandMap
	ActionMap          map[string]func()
	ActionOneStringMap map[string]func([]string)
}

func New

func New() *Shell

func (*Shell) ConfigMap

func (s *Shell) ConfigMap(configuration *CommandsConfiguration) *Shell

func (*Shell) Help

func (s *Shell) Help()

func (*Shell) Input

func (s *Shell) Input() string

func (*Shell) LoadConfiguration

func (s *Shell) LoadConfiguration(configFile string) *Shell

func (*Shell) SetActions

func (s *Shell) SetActions(actions map[string]func()) *Shell

func (*Shell) SetActionsStrings

func (s *Shell) SetActionsStrings(actions map[string]func([]string)) *Shell

func (*Shell) SetConfiguration

func (s *Shell) SetConfiguration(configuration *CommandsConfiguration) *Shell

func (*Shell) SetPrompt

func (s *Shell) SetPrompt(name string) *Shell

func (*Shell) Start

func (s *Shell) Start()

Jump to

Keyboard shortcuts

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