tui: github.com/vtuson/tui Index | Files | Directories

package tui

import "github.com/vtuson/tui"

This is a Basic Implementation of a text ui that can be used to run CLI commands or you can define your own HandlerCommand to run Go functions Basic Structure is: Menu

[]Command
     []Args

By default a CLI command handler is provided that is able to pass parameters as flag, options or Enviroment variables

You can find an example app in the /example folder

Index

Package Files

commands.go print.go progressbar.go

func OSCmdHandler Uses

func OSCmdHandler(c *Command, ch chan string)

OS execution default handler Error in command is updated in completion

type Argument Uses

type Argument struct {
    Envar       string
    Name        string
    IsFlag      bool
    Title       string
    Description string
    Value       string
    IsBoolean   bool
    Valuebool   bool
}

Argument can be a flag (IsFlag) or a Envar (if defined). If IsFalg is false the Name is passed without a - appended IsBoolean means that the argument is passed with no additional value flag bool: -foo flag: -foo bar noflag bool: foo

type Command Uses

type Command struct {
    Title       string
    Description string
    Cli         string
    Execute     HandlerCommand
    Args        []Argument
    Optional    bool
    Selected    bool
    Error       error
    Success     string
    Fail        string

    Disable bool
    Status  string

    PrintOut bool
    // contains filtered or unexported fields
}

func (*Command) BreadCrum Uses

func (c *Command) BreadCrum() string

gets a breadcrum for a command

type HandlerCommand Uses

type HandlerCommand func(c *Command, screen chan string)

type def for a handler function, pass a command and a channel to return screen stdout, channel will be close when execution is completed

type Menu struct {
    Title         string
    Description   string
    Commands      []Command
    Cursor        int
    BottomBar     bool
    BottomBarText string   //text for default top menu
    BackText      string   //text for back text on command
    BoolText      string   //text when an arg is a bool
    ValueText     string   //text when an arg is a value string
    Wait          chan int //channel to wait completion
    // contains filtered or unexported fields
}

func NewMenu Uses

func NewMenu(style *Style) *Menu

Returns an initialised default Menu

func (m *Menu) BreadCrum() string

gets a breadcrum for a menus

func (m *Menu) CurrentCommand() *Command
func (menu *Menu) EventCommandManager()

Handles key events for commnands

func (menu *Menu) EventManager()

Handles Key events for Menu

func (m *Menu) IsToggle() bool
func (m *Menu) Next()

Moves to the next command in a list

func (m *Menu) NextArgument()

Moves menu to the Next Argument in a Command

func (m *Menu) Prev()

Moves back to the prev command

func (m *Menu) Quit()

Leaves a menu

func (m *Menu) RunCommand(c *Command)

Run commands and waits to complete, then calls menu ShowResult

func (m *Menu) SelectToggle()
func (m *Menu) Show()

Show Menu

func (m *Menu) ShowCommand()

Displays a command in the screen as incated by Cursor in Menu

func (m *Menu) ShowResult(c *Command)

Displays result of running a command, using test Fail and Success, plus adds error message for Fail

type Printing Uses

type Printing struct {
    Cursor int
    // contains filtered or unexported fields
}

func NewPrinting Uses

func NewPrinting(s tcell.Screen, style *Style) *Printing

returns printing object

func (*Printing) Bottom Uses

func (p *Printing) Bottom()

moves cursor to the last line

func (*Printing) BottomBar Uses

func (p *Printing) BottomBar(str string)

prints the bottome bar

func (*Printing) Clear Uses

func (p *Printing) Clear()

Clears screen and goes back to the top

func (*Printing) Put Uses

func (p *Printing) Put(str string, highlight bool)

same as Putln but continues on x

func (*Printing) PutEcho Uses

func (p *Printing) PutEcho(str string, style tcell.Style)

prints string but does not move cursor

func (*Printing) PutH1 Uses

func (p *Printing) PutH1(str string, highlight bool)

putsln with H1 style

func (*Printing) Putln Uses

func (p *Printing) Putln(str string, highlight bool)

adds a ln with a return at the end. hightlight uses the highlight style for the full line text

func (*Printing) PutlnDisable Uses

func (p *Printing) PutlnDisable(str string)

add a line disabled style

func (*Printing) Return Uses

func (p *Printing) Return()

add blank line

func (*Printing) Screen Uses

func (p *Printing) Screen() tcell.Screen

gets the screen object

func (*Printing) Show Uses

func (p *Printing) Show()

shows the screen

func (*Printing) Sync Uses

func (p *Printing) Sync()

syncs the screen

func (*Printing) Top Uses

func (p *Printing) Top()

moves cursor to the top

type ProgressBar Uses

type ProgressBar struct {
    Interval int

    Text string
    // contains filtered or unexported fields
}

func NewProgressBar Uses

func NewProgressBar(p *Printing) *ProgressBar

func (*ProgressBar) Start Uses

func (p *ProgressBar) Start()

func (*ProgressBar) Stop Uses

func (p *ProgressBar) Stop()

type Style Uses

type Style struct {
    Indent     int
    Hightlight tcell.Style
    Default    tcell.Style
    Menu       tcell.Style
    H1         tcell.Style
    Input      tcell.Style
    Disable    tcell.Style
}

Defines style to be used on a menu Default styles are provide Indent is the number of spaces from the right side

func DefaultStyle Uses

func DefaultStyle() *Style

returns default style

Directories

PathSynopsis
sampleapp

Package tui imports 8 packages (graph) and is imported by 1 packages. Updated 2018-02-15. Refresh now. Tools for package owners.