Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
Name string // commands name
MinNumOfArgs int // minium number of arguments needed to run command
Handler HandlerType // the `HandlerType` for this command
Data map[string]interface{} // data stored for the command
}
Command type, use
NewCommand()
to create a new Command
func NewCommand ¶
func NewCommand(name string, minNumOfArgs int, handler HandlerType) *Command
NewCommand returns a `Command` type, Args:
name // name used to call command minNumOfArgs // minimum number of arguments needed for command to run (the `Shell` won't call the command without enough args) handler // the handler to call for the command
type CommandInput ¶
type CommandInput struct {
Shell *Shell // the `Shell` type
Stdout io.Writer // write any command output to here, avoid printing to `os.Stdout`
Args []string // command-line arguments
Cmd *Command // the `Command` type
}
CommandInput is the input type for `CommandHandler` function
type HandlerType ¶
type HandlerType func(*CommandInput) error
HandlerType is the type for
Command.Handler
Its a function called when running its command
type Shell ¶
type Shell struct {
LinePrefix string // Prefix printed at beginning of every command line
Path map[string]*Command // Similar to unix $PATH
// contains filtered or unexported fields
}
Shell type the main part of the program, use
NewShell()
to create a new Shell
func NewShell ¶
Return a new `Shell` and any `error` that occurred. Takes as input a `[]Command` that the shell should know how to run, Use the `NewCommand` function to create new `Command`s NewShell is the constructor for `Shell` type
func (*Shell) GetHistory ¶
GetHistory returns command history similar to Unix history, user can use default `history` command to display history
Click to show internal directories.
Click to hide internal directories.