mirror of
https://github.com/daylinmorgan/bbansi.git
synced 2024-11-21 17:00:44 -06:00
add basic cli
This commit is contained in:
parent
887a724606
commit
0df16a2654
3 changed files with 46 additions and 6 deletions
|
@ -53,6 +53,44 @@ proc bb*(s: string): string =
|
|||
result.add "\e[0m"
|
||||
|
||||
when isMainModule:
|
||||
import std/[strformat, parseopt]
|
||||
const version = staticExec "git describe --tags --always --dirty=-dev"
|
||||
let help = &"""
|
||||
{bb"[bold]bbansi[/] [green]<args>[/] [black]<-h|-v>[/]"}
|
||||
|
||||
usage:
|
||||
bbansi "[yellow] yellow text!"
|
||||
|-> {bb"[yellow] yellow text!"}
|
||||
bbansi "[bold red] bold red[/] plain text..."
|
||||
|-> {bb"[bold red] bold red text[/] plain text..."}
|
||||
"""
|
||||
proc writeHelp() =
|
||||
echo help
|
||||
quit(QuitSuccess)
|
||||
proc writeVersion() =
|
||||
echo "bbansi version -> ", version
|
||||
quit(QuitSuccess)
|
||||
var strArgs: seq[string]
|
||||
var p = initOptParser()
|
||||
for kind, key, val in p.getopt():
|
||||
case kind:
|
||||
of cmdEnd: break
|
||||
of cmdShortOption, cmdLongOption:
|
||||
case key:
|
||||
of "help", "h": writeHelp()
|
||||
of "version","v": writeVersion()
|
||||
else:
|
||||
echo bb"[red]ERROR[/]: unexpected option/value -> ", key, ", ", val
|
||||
echo "Option and value: ", key, ", ", val
|
||||
|
||||
of cmdArgument:
|
||||
strArgs.add key
|
||||
|
||||
if strArgs.len != 0:
|
||||
for arg in strArgs:
|
||||
echo arg.bb
|
||||
else:
|
||||
echo "[bold]---------------------".bb
|
||||
echo bb"[bold]bold"
|
||||
echo bb"[red]red"
|
||||
echo bb"[bold red]bold red"
|
||||
|
|
|
@ -5,6 +5,7 @@ export strtabs
|
|||
|
||||
let bbReset* ="\e[0m"
|
||||
|
||||
# should these be an enum?
|
||||
let
|
||||
codeMap* = {
|
||||
"reset":"0",
|
||||
|
|
1
todo.md
1
todo.md
|
@ -1,5 +1,6 @@
|
|||
# bbansi todo's
|
||||
|
||||
- [ ] make unknown style error with compile time flag
|
||||
- [ ] use an actual type and `$` mechanism
|
||||
- [ ] add better escaping mechanism for bracketed text
|
||||
- [ ] add support for custom 1-256 numbers and 8-bit numbers and truecolor
|
||||
|
|
Loading…
Reference in a new issue