cmdfolder

package module
v0.0.0-...-70ad955 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2015 License: MIT Imports: 7 Imported by: 2

README

CmdFolder GoDoc

CmdFolder is a wrapper around pseudo-terminal-go that allows the creation of mock terminal environments with "folders" that the user can cd into and "commands" that may reside in these folders.

Usage

func main() {
	folder := New()
	folder.AddCommand("do", dostuff)
	folder.Run()
}

func dostuff(_ string) {
	fmt.Println("STUFF GOT DID")
}
  • Note: subfolders haven't happened yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFolder

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

DefaultFolder is a struct that holds data and methods for a command folder

func (*DefaultFolder) AddCommand

func (folder *DefaultFolder) AddCommand(command string, function func(string))

AddCommand adds a function as a command to the folder

func (*DefaultFolder) AddFolder

func (folder *DefaultFolder) AddFolder(name string, subfolder Folder)

AddFolder adds another folder instance as a child of the current folder

func (*DefaultFolder) Ls

func (folder *DefaultFolder) Ls(_ string)

Ls is the default ls command function which lists the subfolders. It may be overridden.

func (*DefaultFolder) Run

func (folder *DefaultFolder) Run()

Run starts the command environment

func (*DefaultFolder) RunWithTerm

func (folder *DefaultFolder) RunWithTerm(prompt string, term *terminal.Terminal)

RunWithTerm is used between folder instances to reuse the terminal object and prompt string

type Folder

type Folder interface {
	AddCommand(string, func(string))
	AddFolder(string, Folder)
	Run()
	RunWithTerm(string, *terminal.Terminal)

	// Folder default commands
	Ls(string)
}

Folder is an interface... I don't know what I'm doing.

func New

func New() Folder

New creates a new command folder

Jump to

Keyboard shortcuts

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