mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-12-22 03:00:43 -06:00
simplify bbansi help generation
This commit is contained in:
parent
38b1854c12
commit
5ee8117e96
1 changed files with 14 additions and 19 deletions
|
@ -176,9 +176,17 @@ when isMainModule:
|
||||||
import std/[parseopt, strformat, sugar]
|
import std/[parseopt, strformat, sugar]
|
||||||
const version = staticExec "git describe --tags --always --dirty=-dev"
|
const version = staticExec "git describe --tags --always --dirty=-dev"
|
||||||
const longOptPad = 8
|
const longOptPad = 8
|
||||||
|
const flags = collect(
|
||||||
|
for (s, l, d) in [
|
||||||
|
("h", "help", "show this help"),
|
||||||
|
("v", "version", "show version"),
|
||||||
|
("s", "style", "set style for string"),
|
||||||
|
]:
|
||||||
|
fmt" [yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}"
|
||||||
|
).join("\n")
|
||||||
proc writeHelp() =
|
proc writeHelp() =
|
||||||
let help =
|
let help =
|
||||||
fmt"""
|
bbfmt"""
|
||||||
[bold]bbansi[/] \[[green]args...[/]] [[[faint]-h|-v[/]]
|
[bold]bbansi[/] \[[green]args...[/]] [[[faint]-h|-v[/]]
|
||||||
|
|
||||||
[italic]usage[/]:
|
[italic]usage[/]:
|
||||||
|
@ -190,22 +198,9 @@ when isMainModule:
|
||||||
|-> [italic][red]some red[/red] but all italic[/italic]
|
|-> [italic][red]some red[/red] but all italic[/italic]
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
""".bb &
|
{flags}
|
||||||
$(
|
"""
|
||||||
bb(
|
echo help; quit 0
|
||||||
collect(
|
|
||||||
for (s, l, d) in [
|
|
||||||
("h", "help", "show this help"),
|
|
||||||
("v", "version", "show version"),
|
|
||||||
("s", "style", "set style for string"),
|
|
||||||
]:
|
|
||||||
fmt"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}"
|
|
||||||
)
|
|
||||||
.join("\n ")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
echo help
|
|
||||||
quit(QuitSuccess)
|
|
||||||
|
|
||||||
proc testCard() =
|
proc testCard() =
|
||||||
for style in [
|
for style in [
|
||||||
|
@ -228,8 +223,8 @@ flags:
|
||||||
echo ")"
|
echo ")"
|
||||||
|
|
||||||
proc writeVersion() =
|
proc writeVersion() =
|
||||||
echo fmt"[yellow]bbansi version[/][red] ->[/] [bold]{version}[/]".bb
|
echo bbfmt"[yellow]bbansi version[/][red] ->[/] [bold]{version}[/]"
|
||||||
quit(QuitSuccess)
|
quit 0
|
||||||
|
|
||||||
var
|
var
|
||||||
strArgs: seq[string]
|
strArgs: seq[string]
|
||||||
|
|
Loading…
Reference in a new issue