osal.tmux #
TMUX
TMUX is a very capable process manager.
Concepts
- tmux = is the factory, it represents the tmux process manager, linked to a node
- session = is a set of windows, it has a name and groups windows
- window = is typically one process running (you can have panes but in our implementation we skip this)
structure
tmux library provides functions for managing tmux sessions
- session is the top one
- then windows (is where you see the app running)
- then panes in windows (we don't support yet)
to attach to a tmux session
TODO:
fn new #
fn new(args TmuxNewArgs) !Tmux
return tmux instance
fn (Session) create #
fn (mut s Session) create() !
fn (Session) restart #
fn (mut s Session) restart() !
fn (Session) stop #
fn (mut s Session) stop() !
fn (Session) str #
fn (mut s Session) str() string
fn (Session) window_delete #
fn (mut s Session) window_delete(args_ WindowGetArgs) !
fn (Session) window_get #
fn (mut s Session) window_get(args_ WindowGetArgs) !&Window
fn (Session) window_new #
fn (mut s Session) window_new(args WindowArgs) !Window
window_name is the name of the window in session main (will always be called session main) cmd to execute e.g. bash file environment arguments to use reset, if reset it will create window even if it does already exist, will destroy it
struct WindowArgs {
pub mut:
name string
cmd string
env map[string]string
reset bool
}
fn (Session) windownames_get #
fn (mut s Session) windownames_get() []string
fn (Session) windows_get #
fn (mut s Session) windows_get() []&Window
get all windows as found in a session
fn (Window) create #
fn (mut w Window) create() !
fn (Window) check #
fn (mut w Window) check() !
do some good checks if the window is still active not implemented yet
fn (Window) restart #
fn (mut w Window) restart() !
restart the window
fn (Window) stop #
fn (mut w Window) stop() !
stop the window
fn (Window) str #
fn (window Window) str() string
fn (Window) environment_print #
fn (mut w Window) environment_print() !
show the environment
fn (Window) output_print #
fn (mut w Window) output_print() !
capture the output
fn (Window) output #
fn (mut w Window) output() !string
capture the output
fn (Window) output_wait #
fn (mut w Window) output_wait(c_ string, timeoutsec int) !
struct SessionCreateArgs #
struct SessionCreateArgs {
pub mut:
name string @[required]
reset bool
}
struct Tmux #
struct Tmux {
pub mut:
sessions []&Session
sessionid string // unique link to job
}
fn (Tmux) is_running #
fn (mut t Tmux) is_running() !bool
checks whether tmux server is running
fn (Tmux) list_print #
fn (mut t Tmux) list_print()
print list of tmux sessions
fn (Tmux) load #
fn (mut tmux Tmux) load() !
loads tmux session, populate the object
fn (Tmux) scan #
fn (mut t Tmux) scan() !
scan the system to detect sessions .
fn (Tmux) session_create #
fn (mut t Tmux) session_create(args SessionCreateArgs) !&Session
create session, if reset will re-create
fn (Tmux) session_delete #
fn (mut t Tmux) session_delete(name_ string) !
fn (Tmux) session_exist #
fn (mut t Tmux) session_exist(name_ string) bool
fn (Tmux) session_get #
fn (mut t Tmux) session_get(name_ string) !&Session
get session (session has windows) . returns none if not found
fn (Tmux) start #
fn (mut t Tmux) start() !
fn (Tmux) stop #
fn (mut t Tmux) stop() !
fn (Tmux) str #
fn (mut t Tmux) str() string
fn (Tmux) window_delete #
fn (mut t Tmux) window_delete(args WindowGetArgs) !
is always in the main tmux
fn (Tmux) window_new #
fn (mut t Tmux) window_new(args WindowArgs) !Window
window_name is the name of the window in session main (will always be called session main) cmd to execute e.g. bash file environment arguments to use reset, if reset it will create window even if it does already exist, will destroy it
struct WindowArgs {
pub mut:
name string
cmd string
env map[string]string
reset bool
}
fn (Tmux) windows_get #
fn (mut t Tmux) windows_get() []&Window
get all windows as found in all sessions
struct TmuxNewArgs #
struct TmuxNewArgs {
sessionid string
}
struct WindowArgs #
struct WindowArgs {
pub mut:
name string
cmd string
env map[string]string
reset bool
}
struct WindowGetArgs #
struct WindowGetArgs {
pub mut:
name string
cmd string
id int
}