Documentation ¶
Index ¶
- Variables
- func PrepareGrid(gridKey string) ([][]string, error)
- type Command
- type CommandExecutor
- type Config
- type Dimension
- type DimensionUsingTerm
- type ICommandExecutor
- type NOOPExecutor
- type Pane
- type Session
- type TerminalDimension
- type TmuxCmdResponse
- type TmuxError
- type TmuxWrapper
- type Window
- type WindowOptions
Constants ¶
This section is empty.
Variables ¶
var CommandName = "tmux"
CommandName contains the tmux name. Not hardcoded in the command itself because it can be used in testcases to run a mock command
var ErrInvalidDimensionError = errors.New("invalid grid found! all rows must have same number of columns and vice versa")
ErrInvalidDimensionError is returned if the grid has invalid dimensions
Functions ¶
func PrepareGrid ¶
PrepareGrid converts the freetext grid into a 2D string array
Types ¶
type Command ¶
type Command struct { Name string `mapstructure:"pane"` CommandText string `mapstructure:"command"` WorkingDirectory string `mapstructure:"workdir"` }
Command represents a command fragment that will be executed in the pane whose name will be same as name in this struct. WorkingDirectory is the location in which all the commands will be executed. The working directory can be passed to tmux split-window command with -c flag but doing that will not create the pane if the working directory is wrong. So, in this implementation, passing the working directory is deferred until the pane has been created.
type CommandExecutor ¶
type CommandExecutor struct { }
CommandExecutor implements the command execution on a shell
func NewCommandExecutor ¶
func NewCommandExecutor() *CommandExecutor
NewCommandExecutor constructs a CommandExecutor
type Dimension ¶
Dimension represents the dimension of the terminal in which binary is executed in.
func NewDimension ¶
NewDimension constructs a dimension
type DimensionUsingTerm ¶
type DimensionUsingTerm struct { }
DimensionUsingTerm uses golang/x/term to find the dimensions of the current shell. There can be other implementations using:
- tput cols and tput size
- stty size
func (*DimensionUsingTerm) Dimension ¶
func (d *DimensionUsingTerm) Dimension() (*Dimension, error)
Dimension fails if the binary is being executed in a terminal
type ICommandExecutor ¶
type ICommandExecutor interface {
Execute(name string, args ...string) (string, string, int, error)
}
ICommandExecutor is implemented by command executor
type NOOPExecutor ¶
type NOOPExecutor struct { }
NOOPExecutor is used for dry runs
func NewNOOPExecutor ¶
func NewNOOPExecutor() *NOOPExecutor
NewNOOPExecutor is a constructor for NOOPExecutor
type Pane ¶
type Pane struct { Name string // Name of the pane XStart int // First index in the horizontal direction XEnd int // Last index in the horizontal direction YStart int // First index in the vertical direction YEnd int // Last index in the vertical direction Visited bool // If this node was visited while traversal Left []*Pane // Collection of the panes to the left of the current pane Bottom []*Pane // Collection of the panes to the bottom of the current pane // contains filtered or unexported fields }
Pane represents a TMUX pane in a 2D grid
func PrepareGraph ¶
PrepareGraph converts a 2D grid into a graph of panes It returns the first pane that will contain further panes based on the hierarchy
func (*Pane) AddBottomPane ¶
AddBottomPane appends a bottom pane to the current pane
func (*Pane) AddLeftPane ¶
AddLeftPane appends left pane to the current pane
type Session ¶
type Session struct { Name string `mapstructure:"name"` Windows []*Window `mapstructure:"windows"` }
Session represents one TMUX session from the config
type TerminalDimension ¶
TerminalDimension can be implemented by the providers of terminal dimensions
type TmuxCmdResponse ¶
TmuxCmdResponse is a parsed response from Tmux commands
type TmuxError ¶
type TmuxError struct {
// contains filtered or unexported fields
}
TmuxError is returned after the execution of TMUX commands
func NewTmuxError ¶
NewTmuxError is a constructor TmuxError
type TmuxWrapper ¶
type TmuxWrapper struct {
// contains filtered or unexported fields
}
TmuxWrapper implements the logic to convert the pane and config into TMUX panes and command executions
func NewTmuxWrapper ¶
func NewTmuxWrapper(config *Config, dimensions *Dimension) *TmuxWrapper
NewTmuxWrapper constructs a TmuxWrapper
func (*TmuxWrapper) Apply ¶
func (t *TmuxWrapper) Apply() error
Apply does on each session:
- checks if the requested session is already present
- creates a new session for the current config
- creates windows and panes
- executes the command of the provided config
type Window ¶
type Window struct { Name string `mapstructure:"name"` Grid string `mapstructure:"grid"` FirstPane *Pane Commands []*Command `mapstructure:"commands"` Options *WindowOptions `mapstructure:"options"` }
Window represents one TMUX window from the config
type WindowOptions ¶
type WindowOptions struct {
SynchronizePanes bool `mapstructure:"sync"`
}