From 46d4dfd0106555025f6295a2b999a23a3a073ee9 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Fri, 27 Sep 2024 10:42:17 -0500 Subject: [PATCH] refactor: switch to hwyl-based cligen --- nimble.lock | 14 +++++++------- src/tsm.nim | 27 ++++----------------------- tsm.nimble | 2 +- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/nimble.lock b/nimble.lock index a2db223..d356842 100644 --- a/nimble.lock +++ b/nimble.lock @@ -2,23 +2,23 @@ "version": 2, "packages": { "cligen": { - "version": "1.7.0", - "vcsRevision": "4193f802796f15559c81c6dd56724d6f20345917", + "version": "1.7.5", + "vcsRevision": "85daafd76b0104387f50ff3f75c829b4c2804412", "url": "https://github.com/c-blake/cligen.git", "downloadMethod": "git", "dependencies": [], "checksums": { - "sha1": "300bd7fdb6e48d2d98e34ed0661206b50331e99c" + "sha1": "f3ffe7329c8db755677d3ca377d02ff176cec8b1" } }, "hwylterm": { "version": "0.1.0", - "vcsRevision": "9afc339a9791f25010ea89a4f52204ad8eeda858", + "vcsRevision": "c2bcfd1f73dda97bd3e209c89e2abfe588f0977c", "url": "https://github.com/daylinmorgan/hwylterm", "downloadMethod": "git", "dependencies": [], "checksums": { - "sha1": "853c67ee7f789d825ec6f46c9fbae68e03e43cdb" + "sha1": "1932229840c893c39acca0b50def19913678f5f0" } }, "illwill": { @@ -33,12 +33,12 @@ }, "usu": { "version": "0.1.0", - "vcsRevision": "25574d165bb7f60900b36590bc49f3d90e47cea4", + "vcsRevision": "ab2406bd5b857f44c9ebee8ed5f7287b30e089dd", "url": "https://github.com/usu-dev/usu-nim", "downloadMethod": "git", "dependencies": [], "checksums": { - "sha1": "61a8c13946e3eea9dbe04a6141ed93811563026c" + "sha1": "f9414616e9e7b225257b78caeb7438a52347f010" } } }, diff --git a/src/tsm.nim b/src/tsm.nim index b6aaeb2..c9850d3 100644 --- a/src/tsm.nim +++ b/src/tsm.nim @@ -22,27 +22,8 @@ proc getVersion(): string = when isMainModule: - import cligen + import cligen, hwylterm, hwylterm/cli clCfg.version = getVersion() - - if clCfg.helpAttr.len == 0: - 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 - - dispatch(tsm, short = {"version": 'v'}) + hwylCli(clCfg) + let clUse* = $bb("$command $args\n${doc}[bold]Options[/]:\n$options") + dispatch(tsm, usage = clUse, short = {"version": 'v'}) diff --git a/tsm.nimble b/tsm.nimble index 985b7dd..cd4035e 100644 --- a/tsm.nimble +++ b/tsm.nimble @@ -13,6 +13,6 @@ binDir = "bin" requires "nim >= 2.0.0" requires "illwill >= 0.4.1" requires "cligen" -requires "https://github.com/daylinmorgan/hwylterm" +requires "https://github.com/daylinmorgan/hwylterm#HEAD" requires "https://github.com/usu-dev/usu-nim"