change call to node for readability

This commit is contained in:
Daylin Morgan 2024-11-14 11:05:45 -06:00
parent 203082d893
commit 5f5dd86c4d
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -562,42 +562,41 @@ func parseCliHelp(c: var CliCfg, node: NimNode) =
func parseCliBody(body: NimNode, name = "", root = false): CliCfg = func parseCliBody(body: NimNode, name = "", root = false): CliCfg =
result.name = name result.name = name
result.root = root result.root = root
# TDOO: change call to n or node? for node in body:
for call in body: if node.kind notin [nnkCall, nnkCommand, nnkPrefix]:
if call.kind notin [nnkCall, nnkCommand, nnkPrefix]: error "unexpected node kind: " & $node.kind
error "unexpected node kind: " & $call.kind let name = node[0].strVal
let name = call[0].strVal
case name: case name:
of "name": of "name":
expectKind call[1], nnkStrLit expectKind node[1], nnkStrLit
result.name = call[1].strVal result.name = node[1].strVal
of "alias": of "alias":
if root: error "alias not supported for root command" if root: error "alias not supported for root command"
pasrseCliAlias(result, call) pasrseCliAlias(result, node)
of "version", "V": of "version", "V":
result.version = call[1] result.version = node[1]
of "usage", "?": of "usage", "?":
result.help.usage = call[1] result.help.usage = node[1]
of "...", "help": of "...", "help":
parseCliHelp(result, call) parseCliHelp(result, node)
of "flags": of "flags":
parseCliFlags(result, call[1]) parseCliFlags(result, node[1])
of "settings": of "settings":
parseCliSettings(result, call) parseCliSettings(result, node)
of "stopWords": of "stopWords":
result.stopWords = parseIdentLikeList(call) result.stopWords = parseIdentLikeList(node)
of "subcommands": of "subcommands":
parseCliSubcommands(result, call) parseCliSubcommands(result, node)
of "hidden": of "hidden":
parseHiddenFlags(result, call) parseHiddenFlags(result, node)
of "run": of "run":
result.run = call[1] result.run = node[1]
of "required": of "required":
result.required = parseIdentLikeList(call) result.required = parseIdentLikeList(node)
of "preSub": of "preSub":
result.preSub = call[1] result.preSub = node[1]
of "postSub": of "postSub":
result.postSub = call[1] result.postSub = node[1]
else: else:
error "unknown hwylCli setting: " & name error "unknown hwylCli setting: " & name