README
¶
Turban Shell
A simple shell experience.
Turban Application
There is a turban shell application available in the cmd directory. It reads a TURBAN.toml file and provides a simple shell.
go get -u github.com/desertbit/turban
go install github.com/desertbit/turban/cmd/turban
turban -p "prompt text" -d "path to directory"
Library Sample
package main
import (
"fmt"
"github.com/desertbit/turban"
)
func main() {
turban.SetPrompt("TURBAN » ")
turban.SetHelpHeader("TURBAN - A simple shell experience")
turban.SetPrintASCIIArtFunc(printASCIIArt)
turban.AddCommand("foo", &turban.Command{
Help: "Print foo help text",
Usage: "foo [BAR]",
Run: func(args []string) error {
// ...
return nil
},
})
turban.Run(true)
}
func printASCIIArt() {
fmt.Println("____ _ _ ___ ___ __ _ _ ")
fmt.Println(" )) ))`) ))_) ))_) /_`) )\\`)")
fmt.Println("(( ((_( ((`\\ ((__)(( ( ((`( ")
fmt.Println("")
}
Documentation
¶
Overview ¶
Package turban offers a simple shell experience.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidUsage when returned by the Run Command function, // then usage is printed. ErrInvalidUsage = errors.New("invalid usage") )
Functions ¶
func AddCommand ¶
AddCommand register a new shell command.
func AskForConfirmation ¶
AskForConfirmation asks the user for confirmation. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user.
func SetHelpHeader ¶
func SetHelpHeader(h string)
SetHelpHeader sets the header displayed in the help.
func SetPrintASCIIArtFunc ¶
func SetPrintASCIIArtFunc(f func())
SetPrintASCIIArtFunc sets the function which is called when the ASCII art logo should be printed.