From 57e99e8f27cdf4550c2166968da364277789ede0 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sat, 28 Sep 2024 18:02:04 -0500 Subject: [PATCH] add more convience combiner procs --- pkgs/oizys-nim/config.nims | 2 -- pkgs/oizys-nim/src/oizys.nim | 29 +++++++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pkgs/oizys-nim/config.nims b/pkgs/oizys-nim/config.nims index e55e4a1..bbf9469 100644 --- a/pkgs/oizys-nim/config.nims +++ b/pkgs/oizys-nim/config.nims @@ -6,5 +6,3 @@ task build, "build oizys": when withDir(thisDir(), system.fileExists("nimble.paths")): include "nimble.paths" # end Nimble config -# ---path:"../../../dev/github/daylinmorgan/hwylterm/src" diff --git a/pkgs/oizys-nim/src/oizys.nim b/pkgs/oizys-nim/src/oizys.nim index fde49ea..bb64cd9 100644 --- a/pkgs/oizys-nim/src/oizys.nim +++ b/pkgs/oizys-nim/src/oizys.nim @@ -86,10 +86,15 @@ proc checkExes() = if findExe("nix") == "": fatalQuit "oizys requires nix" -proc `//`(t1: Table[string, string], t2: Table[string, string]): Table[string, string] = - # nix style shallow table merge - for k, v in t1.pairs(): result[k] = v - for k, v in t2.pairs(): result[k] = v +func `//`[A, B](pairs: openArray[(A, B)]): Table[A, B] = + pairs.toTable() +func `//`[A, B](t1: var Table[A,B], t2: Table[A,B]) = + for k, v in t2.pairs(): t1[k] = v +func `//`[A, B](t1: Table[A, B], t2: Table[A, B]): Table[A, B] = + result // t1; result // t2 +func `//`[A, B](pairs: openArray[(A,B)], t2: Table[A,B]): Table[A,B] = + // pairs // t2 + when isMainModule: @@ -98,21 +103,21 @@ when isMainModule: hwylCli(clCfg) const - sharedHelp = { + sharedHelp = //{ "flake" : "path/to/flake", "host" : "host(s) to build", "debug" : "enable debug mode", "resetCache" : "set cache timeout to 0" - }.toTable() - updateHelp = { + } + updateHelp = //{ "yes" : "skip all confirmation prompts" - }.toTable() // sharedHelp - ciHelp = { + } // sharedHelp + ciHelp = //{ "ref" : "git ref/branch/tag to trigger workflow on" - }.toTable() - cacheHelp = { + } + cacheHelp = //{ "name" : "name of cachix binary cache" - }.toTable() // sharedHelp + } // sharedHelp let # clUse must be set here using clCfg doesn't seem to work with dispatchMutli ... clUse* = $bb("$command $args\n${doc}[bold]Options[/]:\n$options")