refactor: don't process help string by default

This commit is contained in:
Daylin Morgan 2023-09-20 15:40:55 -05:00
parent 190cf82e6e
commit 5d5b459c95
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F

View file

@ -141,7 +141,8 @@ 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
let help = fmt""" proc writeHelp() =
let help = fmt"""
[bold]bbansi[/] \[[green]args...[/]] [[[faint]-h|-v[/]] [bold]bbansi[/] \[[green]args...[/]] [[[faint]-h|-v[/]]
[italic]usage[/]: [italic]usage[/]:
@ -160,6 +161,8 @@ flags:
]: ]:
fmt"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}").join("\n ") fmt"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}").join("\n ")
)) ))
echo help
quit(QuitSuccess)
proc testCard = proc testCard =
for style in [ for style in [
@ -182,9 +185,7 @@ flags:
echo " escaped: ", escape($bbs) echo " escaped: ", escape($bbs)
echo ")" echo ")"
proc writeHelp() =
echo help
quit(QuitSuccess)
proc writeVersion() = proc writeVersion() =
echo fmt"[yellow]bbansi version[/][red] ->[/] [bold]{version}[/]".bb echo fmt"[yellow]bbansi version[/][red] ->[/] [bold]{version}[/]".bb
quit(QuitSuccess) quit(QuitSuccess)
@ -212,8 +213,7 @@ flags:
of cmdArgument: of cmdArgument:
strArgs.add key strArgs.add key
if strArgs.len == 0: if strArgs.len == 0:
echo help writeHelp()
quit(QuitSuccess)
for arg in strArgs: for arg in strArgs:
let styled = let styled =
if style != "": if style != "":