Console

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HelpOpcode string = "help"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandInfo

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

func NewCommandInfo

func NewCommandInfo(description string, fn ConsoleFunc, args []string) *CommandInfo

func (*CommandInfo) ParseArgs

func (inf *CommandInfo) ParseArgs(args []string) (map[string]any, error)

type Console

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

func NewConsole

func NewConsole() *Console

func (*Console) AddCommand

func (c *Console) AddCommand(name string, info *CommandInfo)

func (*Console) ParseArgs

func (c *Console) ParseArgs(args []string) (*ParsedCommand, error)

type ConsoleFunc

type ConsoleFunc func(flagMap map[string]any) (any, error)

type ParsedCommand

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

func NewParsedCommand

func NewParsedCommand(command string, flagMap map[string]any, fn ConsoleFunc) *ParsedCommand

func (*ParsedCommand) Execute

func (pc *ParsedCommand) Execute() (any, error)

Execute executes the command with the given flags.

Returns:

  • error: An error if the command failed to execute.

func (*ParsedCommand) GetCommand

func (pc *ParsedCommand) GetCommand() string

GetCommand returns the name of the command.

Jump to

Keyboard shortcuts

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