Documentation
¶
Overview ¶
Package gocli is a basic command line interface built on x/term that provides tab autocomplete and exception handling.
Index ¶
- func ChangeAdminPassword(adminName string)
- func CheckArgCount(args []string, nArgs int) (ok bool)
- func Exit()
- func HandleError(err error)
- func ReadLine() (line string, err error)
- func ReadPassword(prompt string) (line string, err error)
- func SetBracketedPasteMode(on bool)
- func SetPrompt(prompt string)
- func SetSize(width int, height int) error
- func Start(c *Context)
- func Write(msg string)
- type Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeAdminPassword ¶
func ChangeAdminPassword(adminName string)
ChangeAdminPassword changes the admin password
func CheckArgCount ¶
CheckArgCount checks that the number of args expected nArgs matches the number of arguments in args
func HandleError ¶
func HandleError(err error)
HandleError handles errors in the standard way, which is to restore terminal to oldState, exit with status 0 for EOF and print the error and exit with status 1 otherwise.
func ReadPassword ¶
func SetBracketedPasteMode ¶
func SetBracketedPasteMode(on bool)
Types ¶
type Context ¶
type Context struct {
// An init function to run before starting the CLI. User can set to "func() {}" if not needed.
Init func()
// The command dispatcher. Dispatches on args which is the line read the command line.
// The first element in args is the command, the remaining elements are the arguments.
Dispatch func(args []string)
// Function that validates the admin password.
AdminPasswordValidator func(adminName, password string) (isPWValid bool, err error)
// Function that updates the admin password.
AdminPasswordUpdater func(adminName, newPassword string) error
// The commands recognized by the CLI.
Cmds []string
StartMsg string
DefaultAdminPassword string
AskToLogin bool // toggles if login is required to use CLI
}
Context defines the context for the CLI, which the user is to provide.
Click to show internal directories.
Click to hide internal directories.