mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-12-22 21:10:43 -06:00
Compare commits
No commits in common. "4b53d3e050e4bb444ef28bdc8c2e11b939d8dfb2" and "544b4f5c6fe8acd1a9529e5604ea2a9ced3161a4" have entirely different histories.
4b53d3e050
...
544b4f5c6f
5 changed files with 54 additions and 17 deletions
10
config.nims
10
config.nims
|
@ -2,9 +2,13 @@ import std/[strformat, strutils]
|
||||||
|
|
||||||
|
|
||||||
task debugSelect, "debug select":
|
task debugSelect, "debug select":
|
||||||
--define:"debugSelect"
|
exec "nim -d:debugSelect c -r src/selector.nim"
|
||||||
--run
|
|
||||||
setCommand("c", "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"
|
||||||
|
|
||||||
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": "2a5dce888d7abf5409a62208d951ac3a4e6babfa",
|
"vcsRevision": "337083afe13bf0f1bd024b870c2174a901e8ce06",
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "56afeceb88973f730111cfa7d02aef2d0cf88197"
|
"sha1": "a995a81f5e4af2991c79ed04b02f17d47dd509e0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"illwill": {
|
"illwill": {
|
||||||
|
|
|
@ -36,11 +36,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730958623,
|
"lastModified": 1726142289,
|
||||||
"narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=",
|
"narHash": "sha256-Jks8O42La+nm5AMTSq/PvM5O+fUAhIy0Ce1QYqLkyZ4=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "85f7e662eda4fa3a995556527c87b2524b691933",
|
"rev": "280db3decab4cbeb22a4599bd472229ab74d25e1",
|
||||||
"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,11 +12,44 @@ 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#2a5dce88"
|
requires "https://github.com/daylinmorgan/hwylterm#HEAD"
|
||||||
requires "https://github.com/usu-dev/usu-nim"
|
requires "https://github.com/usu-dev/usu-nim"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue