go get github.com/theskibb/sShellyou can now import the library with
import(
"github.com/theskibb/sShell/sShell"
)to create a shell using the library you need to create a ShellSettings struct
ShellSettings needs three fields:
- Prompt: the prompt indicator for the shell
- ExitMsg: typing this message will stop the shell
- Commands: an array of Command structs
- DefaultHandler: handles inputs which are not in the commands array
- needs to be a func(args []string) string
- SingleMode: boolean. if set to true, you only get to do one command, the result of which is returned from the StartShell function
Command structs need three fields:
- Input: the command name you write into the shell
- handler: the function which will execute when you run the command
- needs to be a func(args []string) string
- HelpMsg: the string which will be displayed for this command when you run help
for examples of how to use the library, see the examples folder.