mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-12-22 05:00:44 -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":
|
||||
exec "nim -d:debugSelect c -r src/selector.nim"
|
||||
|
||||
task build, "build app":
|
||||
selfExec "c -o:bin/tsm src/tsm.nim"
|
||||
|
||||
task buildRelease, "build release app":
|
||||
selfExec "c -d:release -o:bin/tsm src/tsm.nim"
|
||||
--define:"debugSelect"
|
||||
--run
|
||||
setCommand("c", "src/selector.nim")
|
||||
|
||||
task release, "build release assets w/forge":
|
||||
version = (gorgeEx "git describe --tags --always --match 'v*'").output
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
"packages": {
|
||||
"hwylterm": {
|
||||
"version": "0.1.0",
|
||||
"vcsRevision": "337083afe13bf0f1bd024b870c2174a901e8ce06",
|
||||
"vcsRevision": "2a5dce888d7abf5409a62208d951ac3a4e6babfa",
|
||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [],
|
||||
"checksums": {
|
||||
"sha1": "a995a81f5e4af2991c79ed04b02f17d47dd509e0"
|
||||
"sha1": "56afeceb88973f730111cfa7d02aef2d0cf88197"
|
||||
}
|
||||
},
|
||||
"illwill": {
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1726142289,
|
||||
"narHash": "sha256-Jks8O42La+nm5AMTSq/PvM5O+fUAhIy0Ce1QYqLkyZ4=",
|
||||
"lastModified": 1730958623,
|
||||
"narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "280db3decab4cbeb22a4599bd472229ab74d25e1",
|
||||
"rev": "85f7e662eda4fa3a995556527c87b2524b691933",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
49
src/tsm.nim
49
src/tsm.nim
|
@ -1,6 +1,6 @@
|
|||
import ./[selector, project, tmuxutils]
|
||||
import hwylterm, hwylterm/hwylcli
|
||||
|
||||
# TODO: add option to only opened configured sessions
|
||||
proc tsm(open: bool = false) =
|
||||
let
|
||||
projects = findProjects(open)
|
||||
|
@ -12,44 +12,11 @@ proc tsm(open: bool = false) =
|
|||
else:
|
||||
tmux.attach project.name
|
||||
|
||||
|
||||
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}"
|
||||
|
||||
hwylCli:
|
||||
name "tsm"
|
||||
V tsmVersion
|
||||
flags:
|
||||
open "only search open sessions"
|
||||
run:
|
||||
tsm(open)
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@ binDir = "bin"
|
|||
|
||||
requires "nim >= 2.0.0"
|
||||
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"
|
||||
|
||||
|
|
Loading…
Reference in a new issue