add merger for cligen help

This commit is contained in:
Daylin Morgan 2024-10-01 15:44:00 -05:00
parent 337083afe1
commit 78c177e32e
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -2,6 +2,15 @@
# Hwylterm cligen adapter
Adapter to add hwylterm colors to cligen output.
```nim
import cligen, hwylterm/cligen
proc fun(a: string = "b") =
echo a
hwylCLi(clCfg)
dispatch fun, help = {"a": "option a"}
```
]##
import std/[tables]
@ -48,6 +57,19 @@ const
useHdr = "[bold]Usage[/]:\n "
use = "$command $args\n${doc}[bold]Options[/]:\n$options"
func `//`*[A,B](p: openArray[(A,B)]): Table[A,B] =
p.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](t: Table[A,B], p: openArray[(A,B)]): Table[A,B] =
result // t; result // p.toTable()
func `//`*[A,B](p: openArray[(A,B)], t: Table[A,B]): Table[A,B] =
result // p.toTable(); result // t;
proc hwylCli*(
clcfg: var ClCfg,
styles: CligenStyle = CligenStyle(),