mirror of
https://github.com/daylinmorgan/bbansi.git
synced 2024-11-21 17:00:44 -06:00
feat: start testcard implementation
This commit is contained in:
parent
48cd26b644
commit
32abc9910a
2 changed files with 19 additions and 4 deletions
|
@ -153,6 +153,19 @@ flags:
|
|||
&"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}").join("\n ")
|
||||
))
|
||||
|
||||
proc testCard =
|
||||
for style in [
|
||||
"bold", "faint", "italic", "underline",
|
||||
"blink", "reverse", "conceal", "strike"]:
|
||||
echo style, " -> ", bb(&"[{style}]****")
|
||||
const colors = [
|
||||
"black", "red", "green", "yellow",
|
||||
"blue", "magenta", "cyan", "white", ]
|
||||
for color in colors:
|
||||
echo color, " -> ", bb(&"[{color}]****")
|
||||
for color in colors:
|
||||
echo "on ", color, " -> ", bb(&"[ on {color}]****")
|
||||
|
||||
proc debug(bbs: BbString): string =
|
||||
echo "bbString("
|
||||
echo " raw: ", bbs.raw
|
||||
|
@ -179,6 +192,7 @@ flags:
|
|||
case key:
|
||||
of "help", "h": writeHelp()
|
||||
of "version", "v": writeVersion()
|
||||
of "testCard": testCard(); quit(QuitSuccess)
|
||||
of "style", "s":
|
||||
if val == "":
|
||||
echo "[red]ERROR[/]: expected value for -s/--style".bb
|
||||
|
|
|
@ -3,7 +3,7 @@ import std/[strtabs, strutils]
|
|||
let bbReset* = "\e[0m"
|
||||
|
||||
let
|
||||
bbStyles = {
|
||||
bbStyles* = {
|
||||
"bold": "1",
|
||||
"b": "1",
|
||||
"faint": "2",
|
||||
|
@ -15,9 +15,10 @@ let
|
|||
"reverse": "7",
|
||||
"conceal": "8",
|
||||
"strike": "9",
|
||||
|
||||
}.newStringTable(modeCaseInsensitive)
|
||||
|
||||
bbColors = {
|
||||
bbColors* = {
|
||||
"black": "0",
|
||||
"red": "1",
|
||||
"green": "2",
|
||||
|
@ -32,7 +33,7 @@ proc toAnsiCode*(s: string): string =
|
|||
var
|
||||
styles: seq[string]
|
||||
bgStyle: string
|
||||
if " on " in s:
|
||||
if " on " in s or s.startswith("on"):
|
||||
let fgBgSplit = s.rsplit("on", maxsplit = 1)
|
||||
styles = fgBgSplit[0].splitWhitespace()
|
||||
bgStyle = fgBgSplit[1].strip()
|
||||
|
|
Loading…
Reference in a new issue