Documentation ¶
Overview ¶
Package terminal provides a terminal with support for the generation of GUIs and interactive CLIs for any existing command line tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StructForFlags ¶
StructForFlags returns a new struct object for the given flags.
Types ¶
type App ¶
type App struct { core.Frame // Cmd is the root command associated with this app. Cmd *Cmd // CurCmd is the current root command being typed in. CurCmd string // Dir is the current directory of the app. Dir string }
App is a GUI view of a terminal command.
func NewApp ¶
NewApp returns a new App with the given optional parent: App is a GUI view of a terminal command.
func (*App) MakeToolbar ¶ added in v0.0.3
func (*App) RunCmd ¶
RunCmd runs the given command in the context of the given commands frame and current directory text.
type Cmd ¶
type Cmd struct { // Cmd is the actual name of the command (eg: "git", "go build") Cmd string // Name is the formatted name of the command (eg: "Git", "Go build") Name string // Doc is the documentation for the command (eg: "compile packages and dependencies") Doc string // Flags contains the flags for the command Flags []*Flag // Cmds contains the subcommands of the command Cmds []*Cmd }
Cmd contains all of the data for a parsed command line command.
func NewCmd ¶
NewCmd makes a new App object from the given command name. It does not parse it; see [App.Parse].
func (*Cmd) GetBlocks ¶
func (cm *Cmd) GetBlocks() ([]ParseBlock, error)
GetBlocks gets the ParseBlock objects for this command.
func (*Cmd) GetHelp ¶
GetHelp gets the help information for the command. It tries various different commands and flags to get the help information and only returns an error if all of them fail.
func (*Cmd) SetFromBlocks ¶
func (cm *Cmd) SetFromBlocks(blocks []ParseBlock) error
SetFromBlocks sets the information of the command from the given ParseBlock objects.
type Flag ¶
type Flag struct { // Name is the canonical (longest) name of the flag. // It includes the leading dashes of the flag. Name string // Names are the different names the flag can go by. // They include the leading dashes of the flag. Names []string // Type is the type or value hint for the flag. Type string // Doc is the documentation for the flag. Doc string }
Flag contains the information for a parsed command line flag.
type ParseBlock ¶
ParseBlock is a block of parsed content containing the name of something and the documentation for it.