From 48cd26b644bbbbc053f3452f37d7dd5f1e86b942 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Wed, 13 Sep 2023 02:33:19 -0500 Subject: [PATCH] format: nimpretty did it's thing --- src/bbansi.nim | 10 +++++----- tests/tbasic.nim | 10 ++++++---- tests/tcli.nim | 6 ++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/bbansi.nim b/src/bbansi.nim index ef774bf..7f4a570 100644 --- a/src/bbansi.nim +++ b/src/bbansi.nim @@ -22,13 +22,13 @@ proc `&`*(x: BbString, y: string): BbString = proc `&`*(x: string, y: BbString): BbString = result.raw = x & y.raw result.plain = x & y.plain - result.spans.add BbSpan(styles: @[],slice: [0, x.len-1] ) + result.spans.add BbSpan(styles: @[], slice: [0, x.len-1]) for span in y.spans: let length = x.len styles = span.styles slice = span.slice - result.spans.add BbSpan(styles: styles, slice: [slice[0]+length,slice[1]+length]) + result.spans.add BbSpan(styles: styles, slice: [slice[0]+length, slice[1]+length]) func len*(bbs: BbString): int = bbs.plain.len @@ -151,7 +151,7 @@ flags: ("s", "style", "set style for string") ]: &"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}").join("\n ") - )) + )) proc debug(bbs: BbString): string = echo "bbString(" @@ -179,7 +179,7 @@ flags: case key: of "help", "h": writeHelp() of "version", "v": writeVersion() - of "style", "s": + of "style", "s": if val == "": echo "[red]ERROR[/]: expected value for -s/--style".bb quit(QuitFailure) @@ -193,7 +193,7 @@ flags: echo help quit(QuitSuccess) for arg in strArgs: - let styled = + let styled = if style != "": arg.bb(style) else: arg.bb diff --git a/tests/tbasic.nim b/tests/tbasic.nim index 39338f9..5af7ce1 100644 --- a/tests/tbasic.nim +++ b/tests/tbasic.nim @@ -38,10 +38,12 @@ suite "basic": test "concat-ops": check "[red]RED[/]".bb & " plain string" == "[red]RED[/] plain string".bb check "[red]RED[/]".bb.len == 3 - check bb("[blue]Blue[/]") & " " & bb("[red]Red[/]") == "[blue]Blue[/] [red]Red[/]".bb - check "a plain string" & "[blue] a blue string".bb == "a plain string[blue] a blue string".bb + check bb("[blue]Blue[/]") & " " & bb("[red]Red[/]") == + "[blue]Blue[/] [red]Red[/]".bb + check "a plain string" & "[blue] a blue string".bb == + "a plain string[blue] a blue string".bb test "style full": - check "[red]Red[/red]".bb == bb("Red","red") - check "[b][yellow]not yellow[/][/b]".bb == bb("[yellow]not yellow[/]","b") + check "[red]Red[/red]".bb == bb("Red", "red") + check "[b][yellow]not yellow[/][/b]".bb == bb("[yellow]not yellow[/]", "b") diff --git a/tests/tcli.nim b/tests/tcli.nim index 600b9d9..9780a28 100644 --- a/tests/tcli.nim +++ b/tests/tcli.nim @@ -14,8 +14,10 @@ proc cliRun(cmd: string): string = suite "cli": setup: - let cmd = "nim c -o:" & pathToSrc / "bbansi.out " & (pathToSrc / ".." / "src" / "bbansi.nim") + let cmd = "nim c -o:" & pathToSrc / "bbansi.out " & (pathToSrc / ".." / + "src" / "bbansi.nim") check execCmdEx(cmd).exitCode == 0 test "simple": check "\e[31mRed\e[0m" == cliRun "[red]Red[/]" - check "\e[1m\e[0m\e[1m\e[31mRed\e[0m\e[1m Not Red but Bold\e[0m" == cliRun "'[red]Red[/] Not Red but Bold' " & "--style:bold" + check "\e[1m\e[0m\e[1m\e[31mRed\e[0m\e[1m Not Red but Bold\e[0m" == + cliRun "'[red]Red[/] Not Red but Bold' " & "--style:bold"