mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-11-16 09:18:32 -06:00
update to hwylcli
This commit is contained in:
parent
90e4139284
commit
4b53d3e050
3 changed files with 11 additions and 44 deletions
|
@ -3,12 +3,12 @@
|
||||||
"packages": {
|
"packages": {
|
||||||
"hwylterm": {
|
"hwylterm": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"vcsRevision": "b6202f4f51edadd041d2b5f2aed1d75abcd4ee51",
|
"vcsRevision": "2a5dce888d7abf5409a62208d951ac3a4e6babfa",
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "eb38b434419ec70f080f79b7826c3c3989a2c74a"
|
"sha1": "56afeceb88973f730111cfa7d02aef2d0cf88197"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"illwill": {
|
"illwill": {
|
||||||
|
|
49
src/tsm.nim
49
src/tsm.nim
|
@ -1,6 +1,6 @@
|
||||||
import ./[selector, project, tmuxutils]
|
import ./[selector, project, tmuxutils]
|
||||||
|
import hwylterm, hwylterm/hwylcli
|
||||||
|
|
||||||
# TODO: add option to only opened configured sessions
|
|
||||||
proc tsm(open: bool = false) =
|
proc tsm(open: bool = false) =
|
||||||
let
|
let
|
||||||
projects = findProjects(open)
|
projects = findProjects(open)
|
||||||
|
@ -12,44 +12,11 @@ proc tsm(open: bool = false) =
|
||||||
else:
|
else:
|
||||||
tmux.attach project.name
|
tmux.attach project.name
|
||||||
|
|
||||||
|
hwylCli:
|
||||||
|
name "tsm"
|
||||||
|
V tsmVersion
|
||||||
|
flags:
|
||||||
|
open "only search open sessions"
|
||||||
|
run:
|
||||||
|
tsm(open)
|
||||||
|
|
||||||
# when isMainModule:
|
|
||||||
# import std/parseopt
|
|
||||||
import hwylterm, hwylterm/hwylcli
|
|
||||||
|
|
||||||
const
|
|
||||||
tsmVersion {.strdefine.} =
|
|
||||||
staticExec "git describe --tags --always HEAD --match 'v*'"
|
|
||||||
usage =
|
|
||||||
"""tmux session manager
|
|
||||||
|
|
||||||
[bold]tsm[/] [[[faint]-h|-v|-o[/]]"""
|
|
||||||
flags = [
|
|
||||||
("h","help","show this help"),
|
|
||||||
("v","version", "print version"),
|
|
||||||
("o","open", "only search open sessions")
|
|
||||||
]
|
|
||||||
proc help() = echo newHwylCliHelp(usage = usage, flags = flags)
|
|
||||||
var open: bool
|
|
||||||
var p = initOptParser(
|
|
||||||
shortNoVal = {'h', 'v', 'o'},
|
|
||||||
longNoVal = @["open"]
|
|
||||||
)
|
|
||||||
for kind, key, val in p.getOpt():
|
|
||||||
case kind:
|
|
||||||
of cmdError: assert false
|
|
||||||
of cmdEnd: assert false
|
|
||||||
of cmdArgument:
|
|
||||||
echo bb"[red]Error[/]: unexpected positional argument ", bbfmt"[bold]{key}[/]"
|
|
||||||
of cmdShortOption, cmdLongOption:
|
|
||||||
case key:
|
|
||||||
of "help", "h":
|
|
||||||
help(); quit 0
|
|
||||||
of "version", "v":
|
|
||||||
echo "tsm: " & tsmVersion; quit 0
|
|
||||||
of "open", "o":
|
|
||||||
open = true
|
|
||||||
else:
|
|
||||||
echo bbfmt"[red]Error[/]: unknown key value pair", bbfmt"[b]key[/]: {key}, [b]value[/]: {val}"
|
|
||||||
|
|
||||||
tsm(open)
|
|
||||||
|
|
|
@ -12,6 +12,6 @@ binDir = "bin"
|
||||||
|
|
||||||
requires "nim >= 2.0.0"
|
requires "nim >= 2.0.0"
|
||||||
requires "illwill >= 0.4.1"
|
requires "illwill >= 0.4.1"
|
||||||
requires "https://github.com/daylinmorgan/hwylterm#b6202f4"
|
requires "https://github.com/daylinmorgan/hwylterm#2a5dce88"
|
||||||
requires "https://github.com/usu-dev/usu-nim"
|
requires "https://github.com/usu-dev/usu-nim"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue