improve newlines in help output

This commit is contained in:
Daylin Morgan 2024-11-11 14:38:38 -06:00
parent c0611a728c
commit 0c55d85bda
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -61,14 +61,14 @@ func render*(cli: HwylCliHelp, f: HwylFlagHelp): string =
if f.short != "": if f.short != "":
result.add "[" & cli.styles.flagShort & "]" result.add "[" & cli.styles.flagShort & "]"
result.add "-" & f.short.alignLeft(cli.shortArgLen) result.add "-" & f.short.alignLeft(cli.shortArgLen)
result.add "[/]" result.add "[/" & cli.styles.flagShort & "]"
else: else:
result.add " ".repeat(1 + cli.shortArgLen) result.add " ".repeat(1 + cli.shortArgLen)
result.add " " result.add " "
if f.long != "": if f.long != "":
result.add "[" & cli.styles.flagLong & "]" result.add "[" & cli.styles.flagLong & "]"
result.add "--" & f.long.alignLeft(cli.longArgLen) result.add "--" & f.long.alignLeft(cli.longArgLen)
result.add "[/]" result.add "[/" & cli.styles.flagLong & "]"
else: else:
result.add " ".repeat(2 + cli.longArgLen) result.add " ".repeat(2 + cli.longArgLen)
@ -77,7 +77,7 @@ func render*(cli: HwylCliHelp, f: HwylFlagHelp): string =
if f.description != "": if f.description != "":
result.add "[" & cli.styles.flagDesc & "]" result.add "[" & cli.styles.flagDesc & "]"
result.add f.description result.add f.description
result.add "[/]" result.add "[/" & cli.styles.flagDesc & "]"
result.add "\n" result.add "\n"
func render*(cli: HwylCliHelp, subcmd: HwylSubCmdHelp): string = func render*(cli: HwylCliHelp, subcmd: HwylSubCmdHelp): string =
@ -101,8 +101,8 @@ func render*(cli: HwylCliHelp): string =
result.add "\n" result.add "\n"
result.add cli.desc result.add cli.desc
result.add "\n" result.add "\n"
result.add "\n"
if cli.subcmds.len > 0: if cli.subcmds.len > 0:
result.add "\n"
result.add "[" & cli.styles.header & "]" result.add "[" & cli.styles.header & "]"
result.add "subcommands[/]:\n" result.add "subcommands[/]:\n"
for s in cli.subcmds: for s in cli.subcmds: