Documentation
¶
Index ¶
- Constants
- Variables
- func EmbeddedHistory(file string, maxLines int, enableLocal ...bool) (readline.History, error)
- func ExitCtrlD(c *console.Console)
- func GetFlagKey(parent, child string) string
- func SetupPrompt(m *console.Menu)
- func SwitchMenu(c *console.Console)
- type Flag
- type FlagType
- type IShell
- func (s *IShell) AddChild(parent string, command *ShellCmd)
- func (s *IShell) AddCmd(command *ShellCmd)
- func (s *IShell) SetHistoryFilePath(fPath string, maxLine int, enableLocal ...bool)
- func (s *IShell) SetPrintLogo(f func(_ *console.Console))
- func (s *IShell) SetupPrompt(setp func(*console.Menu))
- func (s *IShell) Start() error
- type IShellFlag
- type Item
- type ShellCmd
Constants ¶
View Source
const (
GroupID string = "core"
)
Variables ¶
View Source
var ( ErrOpenHistoryFile = errors.New("failed to open history file") ErrNegativeIndex = errors.New("cannot use a negative index when requesting historic commands") )
Functions ¶
func EmbeddedHistory ¶
NewSourceFromFile returns a new history source writing to and reading from a file.
func ExitCtrlD ¶
exitCtrlD is a custom interrupt handler to use when the shell readline receives an io.EOF error, which is returned with CtrlD.
func GetFlagKey ¶
func SetupPrompt ¶
setupPrompt is a function which sets up the prompts for the main menu.
func SwitchMenu ¶
Types ¶
type Flag ¶
type Flag struct {
Name string // flag name
Short string // flag shorthand
Type FlagType // flag type
Default string // default value
Usage string // flag help info
}
func (*Flag) GetDefault ¶
type IShell ¶
type IShell struct {
Console *console.Console
SetPrompt func(*console.Menu)
History readline.History
// contains filtered or unexported fields
}
func (*IShell) SetHistoryFilePath ¶
func (*IShell) SetPrintLogo ¶
func (*IShell) SetupPrompt ¶
type IShellFlag ¶
type IShellFlag interface {
GetName() string
GetShort() string
GetType() FlagType
GetDefault() string
GetUsage() string
}
Flags
type ShellCmd ¶
type ShellCmd struct {
Name string // cmd name
Parent string // parent cmd name
HelpStr string // Short for cobra cmd
LongHelpStr string // Long for cobra cmd
Options []*Flag // flags for cobra
Run func(cmd *cobra.Command, args []string)
Children []*ShellCmd
}
func NewShellCmd ¶
func NewShellCmd() (sc *ShellCmd)
Click to show internal directories.
Click to hide internal directories.