mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-11-16 06:28:32 -06:00
add tests for hwylcli
This commit is contained in:
parent
e447fc2b92
commit
337083afe1
4 changed files with 15 additions and 23 deletions
|
@ -2,6 +2,7 @@ import std/[os, strformat, strutils]
|
|||
|
||||
task test, "run tests":
|
||||
selfExec "r tests/tbbansi.nim"
|
||||
selfExec "r tests/tcli.nim"
|
||||
|
||||
task develop, "install cligen for development":
|
||||
exec "nimble install -l 'cligen@1.7.5'"
|
||||
|
|
|
@ -72,6 +72,7 @@ proc bbImpl(cli: HwylCli): string =
|
|||
result.add indent(cli.usage, 2 )
|
||||
result.add "\n"
|
||||
if cli.flags.len > 0:
|
||||
result.add "\n"
|
||||
result.add "[" & cli.styles.hdr & "]"
|
||||
result.add "flags[/]:\n"
|
||||
for f in cli.flags:
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
import std/[
|
||||
compilesettings,
|
||||
os,
|
||||
osproc,
|
||||
strutils,
|
||||
times,
|
||||
unittest
|
||||
]
|
||||
|
||||
const pathToSrc = querySetting(SingleValueSetting.projectPath)
|
||||
|
||||
proc cliRun(cmd: string): string =
|
||||
let (output, _) = execCmdEx(pathToSrc / "bbansi.out " & cmd)
|
||||
return output.strip()
|
||||
import hwylterm, hwylterm/cli
|
||||
|
||||
suite "cli":
|
||||
setup:
|
||||
let
|
||||
cli = pathToSrc / "bbansi.out"
|
||||
srcDir = pathToSrc / ".." / "src"
|
||||
cmd = "nim c -o:" & cli & " " & (srcDir / "bbansi.nim")
|
||||
if not cli.fileExists or getFileInfo(cli).lastWriteTime < getFileInfo(srcDir).lastWriteTime:
|
||||
echo " -> compiling test binary"
|
||||
require execCmdEx(cmd).exitCode == 0
|
||||
test "simple":
|
||||
check "\e[31mRed\e[0m" == cliRun "[red]Red[/]"
|
||||
check "\e[1;31mRed\e[0m\e[1m Not Red but Bold\e[0m" ==
|
||||
cliRun "'[red]Red[/] Not Red but Bold' " & "--style:bold"
|
||||
test "cli":
|
||||
let expected = """[b]test-program[/] [[args...]
|
||||
|
||||
[b cyan]flags[/]:
|
||||
[yellow]-h[/] [magenta]--help [/] []show this help[/]
|
||||
[yellow]-V[/] [magenta]--version[/] []print version[/]
|
||||
"""
|
||||
let cli = newHwylCli("[b]test-program[/] [[args...]",flags = [("h","help","show this help",),("V","version","print version")])
|
||||
check $cli == $bb(expected)
|
||||
|
|
5
todo.md
5
todo.md
|
@ -2,7 +2,8 @@
|
|||
|
||||
- [x] add cligen adapters to add colors with bbansi
|
||||
- [ ] add integration test check cligen
|
||||
- [ ] add generic help generator to accompany parseopt
|
||||
- [x] add generic help generator to accompany parseopt
|
||||
|
||||
## improvements
|
||||
|
||||
- [ ] consider reducing illwill surface to only relevant IO (input) features
|
||||
|
@ -14,7 +15,7 @@
|
|||
- [x] make a basic choose one from list widget
|
||||
- [ ] tables/boxes?
|
||||
- [ ] confirmation proc
|
||||
- [ ]basic progress bar
|
||||
- [ ] basic progress bar
|
||||
- [ ] support for 256 and truecolors
|
||||
- [ ] support for rgb colors
|
||||
- [ ] modify 256 colors w/parser changes to be `"[color(9)]red"` instead of `[9]red`
|
||||
|
|
Loading…
Reference in a new issue