Version: v1.3.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2020 License: MIT Imports: 13 Imported by: 0



Package clide is a package utilized in the automated CLI demo tool clide. This package contains functions for managing and manipulating clide commands, windows, and clide-defined structs.



This section is empty.


This section is empty.


func ListenForKey

func ListenForKey(cfg Config)

ListenForKey blocks execution until a key is pressed. Use in a goroutine to watch in the background

func NewWindow added in v1.3.0

func NewWindow(title string, pos Position) (*sdl.Window, error)

NewWindow creates a new clide window using sdl2

func StringToColor added in v1.1.0

func StringToColor(color string) (sdl.Color, error)

StringToColor converts a rgb or rgba formatted string to an sdl.Color struct


type Colors added in v1.1.0

type Colors struct {
	UserText      string `json:"userText"`
	DirectoryText string `json:"directoryText"`
	PrimaryText   string `json:"primaryText"`
	TerminalBG    string `json:"terminalBG"`

Colors holds information for the color scheme of the terminal window and text

type Command

type Command struct {
	CmdString      string   `json:"cmd"`
	Typed          bool     `json:"typed"`
	Window         string   `json:"window"`
	PreDelay       int      `json:"predelay"`
	PostDelay      int      `json:"postdelay"`
	Timeout        int      `json:"timeout"`
	Hidden         bool     `json:"hidden"`
	WaitForKey     bool     `json:"waitForKey"`
	ClearBeforeRun bool     `json:"clearBeforeRun"`
	Async          bool     `json:"async"`
	HideWindow     bool     `json:"hideWindow"`
	ResizeWindows  []Window `json:"resizeWindows"`

Command holds a single clide command

func (Command) IsInstalled

func (cmd Command) IsInstalled() bool

IsInstalled checks to see if the command is installed on the system

func (Command) Run

func (cmd Command) Run(cfg *Config, typer *Typer, exitChan chan bool) error

Run runs a cli command with options to wait before and after execution

func (Command) Validate

func (cmd Command) Validate() error

Validate checks for potential issues in a Command

type Config

type Config struct {
	User           string    `json:"user"`
	Directory      string    `json:"directory"`
	TypeSpeed      int       `json:"typeSpeed"`
	Humanize       float64   `json:"humanize"`
	HideWarnings   bool      `json:"hideWarnings"`
	ClearBeforeAll bool      `json:"clearBeforeAll"`
	KeyTriggerAll  bool      `json:"keyTriggerAll"`
	HideWindows    bool      `json:"hideWindows"`
	FontPath       string    `json:"fontPath"`
	FontSize       int       `json:"fontSize"`
	Windows        []Window  `json:"windows"`
	TiggerKeys     []string  `json:"triggerKeys"`
	ColorScheme    Colors    `json:"colorScheme"`
	Commands       []Command `json:"commands"`
	TyperList      []*Typer

Config holds the global configuration for a clide demo

func NewDefaultConfig added in v1.3.0

func NewDefaultConfig() (Config, error)

NewDefaultConfig returns a config struct initialized to default values useful for writing to a clide window if no config exists

func (Config) BuildTyperList added in v1.3.0

func (cfg Config) BuildTyperList() ([]*Typer, error)

BuildTyperList creates a window for each window defined in config, and then attaches a typer to each window that is created

func (Config) ClearAllWindows added in v1.3.0

func (cfg Config) ClearAllWindows() error

ClearAllWindows clears all existing windows by referencing all Window objects linked to Typer in cfg.TyperList

func (Config) GetWindow added in v1.3.0

func (cfg Config) GetWindow(name string) *sdl.Window

GetWindow return the window object with the specified name

func (Config) NewTyper added in v1.3.0

func (cfg Config) NewTyper(window *sdl.Window) *Typer

NewTyper creates a new typer referencing the given window

func (Config) Validate

func (cfg Config) Validate() (Config, error)

Validate checks for potential issues in a Config and adds some default values if they are already not present

type Font

type Font struct {
	Path string
	Size int

Font holds font information for printing text

type Position

type Position struct {
	X int32
	Y int32
	H int32
	W int32

Position holds the positional data of a sdl2 surface

type Typer

type Typer struct {
	Window   *sdl.Window
	Pos      Position
	Font     Font
	Speed    int
	Humanize float64
	// contains filtered or unexported fields

Typer holds all information neeeded to type or print text to a window

func (*Typer) ClearWindow added in v1.3.0

func (typer *Typer) ClearWindow(color sdl.Color) error

ClearWindow removes all content on the window specified in typer

func (*Typer) Print added in v1.3.0

func (typer *Typer) Print(text string, color sdl.Color) error

Print prints text to the sdl2 window all at once

func (*Typer) Type added in v1.3.0

func (typer *Typer) Type(text string, color sdl.Color) error

Type prints the text to a sdl2 window and simulates a user typing the string it returns a position struct describing the completed surface

type Window

type Window struct {
	Window *sdl.Window
	Name   string `json:"name"`
	X      int32  `json:"x"`
	Y      int32  `json:"y"`
	Height int32  `json:"height"`
	Width  int32  `json:"width"`

Window holds data for a window created with sdl2

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL