tsm/src/tsm.nim

43 lines
994 B
Nim
Raw Normal View History

2023-09-21 13:43:14 -05:00
import std/[tables]
2023-09-05 13:36:33 -05:00
import selector, project, tmuxutils
2023-09-05 17:02:08 -05:00
2024-03-20 10:17:58 -05:00
# TODO: add option to only opened configured sessions
2023-09-29 14:07:41 -05:00
proc tsm(open: bool = false) =
2023-09-05 13:36:33 -05:00
let
2024-09-13 12:29:41 -05:00
projects = findProjects(open)
project = selectProject projects
2023-09-05 13:36:33 -05:00
selected = project.name
2023-09-21 13:43:14 -05:00
if selected notin tmux.sessions:
2024-09-13 12:29:41 -05:00
tmux.new(project.name, project.location)
2023-09-05 13:36:33 -05:00
else:
2023-09-21 13:43:14 -05:00
tmux.attach project.name
2023-09-05 13:36:33 -05:00
when isMainModule:
import cligen
2023-09-21 13:43:14 -05:00
const vsn = staticExec "git describe --tags --always HEAD --match 'v*'"
2023-09-05 13:36:33 -05:00
clCfg.version = vsn
if clCfg.helpAttr.len == 0:
2024-09-13 14:47:45 -05:00
clCfg.helpAttr =
{
"cmd": "\e[1;36m",
"clDescrip": "",
"clDflVal": "\e[33m",
"clOptKeys": "\e[32m",
"clValType": "\e[31m",
"args": "\e[3m"
}.toTable
clCfg.helpAttrOff =
{
"cmd": "\e[m",
"clDescrip": "\e[m",
"clDflVal": "\e[m",
"clOptKeys": "\e[m",
"clValType": "\e[m",
"args": "\e[m"
}.toTable
2023-09-05 13:36:33 -05:00
2024-09-13 14:47:45 -05:00
dispatch(tsm, short = {"version": 'v'})