Documentation
¶
Overview ¶
Package terminal provides a terminal with support for the generation of GUIs and interactive CLIs for any existing command line tools.
Index ¶
- Variables
- func StructForFlags(flags []*Flag) any
- type App
- func (a *App) AppBar(tb *core.Toolbar)
- func (a *App) Config()
- func (t *App) New() tree.Node
- func (t *App) NodeType() *types.Type
- func (a *App) OnInit()
- func (a *App) RunCmd(cmd string, cmds *core.Frame, dir *core.Label) error
- func (t *App) SetCmd(v *Cmd) *App
- func (t *App) SetCurCmd(v string) *App
- func (t *App) SetDir(v string) *App
- func (t *App) SetTooltip(v string) *App
- type Cmd
- type Flag
- type ParseBlock
Constants ¶
This section is empty.
Variables ¶
var AppType = types.AddType(&types.Type{Name: "cogentcore.org/cogent/terminal.App", IDName: "app", Doc: "App is a GUI view of a terminal command.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Cmd", Doc: "Cmd is the root command associated with this app."}, {Name: "CurCmd", Doc: "CurCmd is the current root command being typed in."}, {Name: "Dir", Doc: "Dir is the current directory of the app."}}, Instance: &App{}})
AppType is the types.Type for App
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 adds a new App with the given name to the given parent: App is a GUI view of a terminal command.
func (*App) RunCmd ¶
RunCmd runs the given command in the context of the given commands frame and current directory label.
func (*App) SetCurCmd ¶
SetCurCmd sets the [App.CurCmd]: CurCmd is the current root command being typed in.
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.