mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-12-22 13:10:43 -06:00
Compare commits
4 commits
544b4f5c6f
...
4b53d3e050
Author | SHA1 | Date | |
---|---|---|---|
4b53d3e050 | |||
90e4139284 | |||
0098a70de1 | |||
eeb6bca377 |
5 changed files with 17 additions and 54 deletions
10
config.nims
10
config.nims
|
@ -2,13 +2,9 @@ import std/[strformat, strutils]
|
||||||
|
|
||||||
|
|
||||||
task debugSelect, "debug select":
|
task debugSelect, "debug select":
|
||||||
exec "nim -d:debugSelect c -r src/selector.nim"
|
--define:"debugSelect"
|
||||||
|
--run
|
||||||
task build, "build app":
|
setCommand("c", "src/selector.nim")
|
||||||
selfExec "c -o:bin/tsm src/tsm.nim"
|
|
||||||
|
|
||||||
task buildRelease, "build release app":
|
|
||||||
selfExec "c -d:release -o:bin/tsm src/tsm.nim"
|
|
||||||
|
|
||||||
task release, "build release assets w/forge":
|
task release, "build release assets w/forge":
|
||||||
version = (gorgeEx "git describe --tags --always --match 'v*'").output
|
version = (gorgeEx "git describe --tags --always --match 'v*'").output
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
"packages": {
|
"packages": {
|
||||||
"hwylterm": {
|
"hwylterm": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"vcsRevision": "337083afe13bf0f1bd024b870c2174a901e8ce06",
|
"vcsRevision": "2a5dce888d7abf5409a62208d951ac3a4e6babfa",
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "a995a81f5e4af2991c79ed04b02f17d47dd509e0"
|
"sha1": "56afeceb88973f730111cfa7d02aef2d0cf88197"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"illwill": {
|
"illwill": {
|
||||||
|
|
|
@ -36,11 +36,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726142289,
|
"lastModified": 1730958623,
|
||||||
"narHash": "sha256-Jks8O42La+nm5AMTSq/PvM5O+fUAhIy0Ce1QYqLkyZ4=",
|
"narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "280db3decab4cbeb22a4599bd472229ab74d25e1",
|
"rev": "85f7e662eda4fa3a995556527c87b2524b691933",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
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/cli
|
|
||||||
|
|
||||||
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 newHwylCli(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 cmdEnd:
|
|
||||||
break
|
|
||||||
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#HEAD"
|
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