cmdhelper

package
v0.0.0-...-81a5a3e Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCommandNotFound     = errors.New("command not found")
	ErrCommandArgsNotFound = errors.New("command arguments not found")
	ErrCommandsMustBeFed   = errors.New("commands must be provided")
)

Functions

func StrArrReplace

func StrArrReplace(spl string, arr, rarr []string) []string

StrArrReplace is to replace an array with a replace array based on a special charcter

Types

type CmdHelper

type CmdHelper struct {
	CommandArgs map[string][]string
	Writer      io.Writer
}

func New

func New(cmds map[string][]string, writer io.Writer) (c *CmdHelper, err error)

New returns new CmdHelper

func NewWithCmds

func NewWithCmds(cmds map[string][]string, writer io.Writer) (c *CmdHelper, err error)

NewWithCmds returns new CmdHelper provided by cmds (map of commands to execute)

func (*CmdHelper) CliRunner

func (c *CmdHelper) CliRunner(name string, input io.Reader, args ...string) (string, error)

func (*CmdHelper) Format

func (c *CmdHelper) Format(cmdKey, spl string, rarr []string)

Forat formats the command array with given replace arr. It uses spl (special char) parameter to replace

func (*CmdHelper) Run

func (c *CmdHelper) Run(name string, input io.Reader, cmdKey string) (string, error)

Jump to

Keyboard shortcuts

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