mirror of
https://github.com/daylinmorgan/bbansi.git
synced 2024-11-22 01:10:44 -06:00
format: nimpretty did it's thing
This commit is contained in:
parent
30a337f755
commit
48cd26b644
3 changed files with 15 additions and 11 deletions
|
@ -22,13 +22,13 @@ proc `&`*(x: BbString, y: string): BbString =
|
||||||
proc `&`*(x: string, y: BbString): BbString =
|
proc `&`*(x: string, y: BbString): BbString =
|
||||||
result.raw = x & y.raw
|
result.raw = x & y.raw
|
||||||
result.plain = x & y.plain
|
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:
|
for span in y.spans:
|
||||||
let
|
let
|
||||||
length = x.len
|
length = x.len
|
||||||
styles = span.styles
|
styles = span.styles
|
||||||
slice = span.slice
|
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
|
func len*(bbs: BbString): int = bbs.plain.len
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ flags:
|
||||||
("s", "style", "set style for string")
|
("s", "style", "set style for string")
|
||||||
]:
|
]:
|
||||||
&"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}").join("\n ")
|
&"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}").join("\n ")
|
||||||
))
|
))
|
||||||
|
|
||||||
proc debug(bbs: BbString): string =
|
proc debug(bbs: BbString): string =
|
||||||
echo "bbString("
|
echo "bbString("
|
||||||
|
|
|
@ -38,10 +38,12 @@ suite "basic":
|
||||||
test "concat-ops":
|
test "concat-ops":
|
||||||
check "[red]RED[/]".bb & " plain string" == "[red]RED[/] plain string".bb
|
check "[red]RED[/]".bb & " plain string" == "[red]RED[/] plain string".bb
|
||||||
check "[red]RED[/]".bb.len == 3
|
check "[red]RED[/]".bb.len == 3
|
||||||
check bb("[blue]Blue[/]") & " " & bb("[red]Red[/]") == "[blue]Blue[/] [red]Red[/]".bb
|
check bb("[blue]Blue[/]") & " " & bb("[red]Red[/]") ==
|
||||||
check "a plain string" & "[blue] a blue string".bb == "a plain string[blue] a blue string".bb
|
"[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":
|
test "style full":
|
||||||
check "[red]Red[/red]".bb == bb("Red","red")
|
check "[red]Red[/red]".bb == bb("Red", "red")
|
||||||
check "[b][yellow]not yellow[/][/b]".bb == bb("[yellow]not yellow[/]","b")
|
check "[b][yellow]not yellow[/][/b]".bb == bb("[yellow]not yellow[/]", "b")
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,10 @@ proc cliRun(cmd: string): string =
|
||||||
|
|
||||||
suite "cli":
|
suite "cli":
|
||||||
setup:
|
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
|
check execCmdEx(cmd).exitCode == 0
|
||||||
test "simple":
|
test "simple":
|
||||||
check "\e[31mRed\e[0m" == cliRun "[red]Red[/]"
|
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"
|
||||||
|
|
Loading…
Reference in a new issue