Skip to content

Commit

Permalink
Rename falseDefault and trueDefault to falseDefaultStr and trueDefaul…
Browse files Browse the repository at this point in the history
…tStr (#239)
  • Loading branch information
AngelEzquerra authored Nov 3, 2024
1 parent b09fe8d commit 2dfb587
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions cligen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ type # Main defns CLI authors need be aware of (besides top-level API calls)
widthEnv*: string ## name of environment var for width override
sigPIPE*: ClSIGPIPE ## `dispatch` use allows end-user SIGPIPE ctrl
minStrQuoting*: bool ## Only quote string defaults when necessary
trueDefault*: string ## How to render a default value of "true"
falseDefault*: string ## How to render a default value of "false"
trueDefaultStr*: string ## How to render a default value of "true"
falseDefaultStr*: string ## How to render a default value of "false"
wrapDoc*: int ## Terminal column to wrap at for doc-like &..
wrapTable*: int ##..Table-like sections. 0 => auto -1 => never

Expand Down Expand Up @@ -82,8 +82,8 @@ var clCfg* = ClCfg(
widthEnv: "CLIGEN_WIDTH",
sigPIPE: spIsOk,
minStrQuoting: false,
trueDefault: "true",
falseDefault: "false")
trueDefaultStr: "true",
falseDefaultStr: "false")

var cgParseErrorExitCode* = 1
{.pop.}
Expand Down Expand Up @@ -516,8 +516,8 @@ macro dispatchGen*(pro: typed{nkSym}, cmdName: string="", doc: string="",
`apId`.shortNoVal = { shortH[0] } # argHelp(bool) updates
`apId`.longNoVal = @[ "help", "help-syntax" ] # argHelp(bool) appends
`apId`.minStrQuoting = `cf`.minStrQuoting
`apId`.trueDefault = `cf`.trueDefault
`apId`.falseDefault = `cf`.falseDefault
`apId`.trueDefaultStr = `cf`.trueDefaultStr
`apId`.falseDefaultStr = `cf`.falseDefaultStr
let `setByParseId`: ptr seq[ClParse] = `setByParse`
let `b0` = ha0("bad" , `cf`); let `b1` = ha1("bad" , `cf`)
let `g0` = ha0("good", `cf`); let `g1` = ha1("good", `cf`)
Expand Down
6 changes: 3 additions & 3 deletions cligen/argcvt.nim
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type ArgcvtParams* = object ## \
shortNoVal*: set[char] ## short options keys where value may be omitted
longNoVal*: seq[string] ## long option keys where value may be omitted
minStrQuoting*: bool ## only quote string defaults when necessary
trueDefault*: string ## How to render a default value of "true"
falseDefault*: string ## How to render a default value of "false"
trueDefaultStr*: string ## How to render a default value of "true"
falseDefaultStr*: string ## How to render a default value of "false"

proc argKeys*(a: ArgcvtParams, argSep="="): string =
## `argKeys` generates the option keys column in help tables
Expand Down Expand Up @@ -79,7 +79,7 @@ proc argParse*(dst: var bool, dfl: bool, a: var ArgcvtParams): bool =

proc argHelp*(dfl: bool; a: var ArgcvtParams): seq[string] =
result = @[ a.argKeys(argSep=""), "bool",
if dfl: a.trueDefault else: a.falseDefault ]
if dfl: a.trueDefaultStr else: a.falseDefaultStr ]
if a.parSh.len > 0:
a.shortNoVal.incl(a.parSh[0]) # bool can elide option arguments.
a.longNoVal.add(move(a.parNm)) # So, add to *NoVal.
Expand Down
4 changes: 2 additions & 2 deletions cligen/clCfgInit.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ proc apply(c: var ClCfg, path: string, plain=false) =
c.noHelpHelp = e.value.optionNormalize in yes
of "minstrquoting":
c.minStrQuoting = e.value.optionNormalize in yes
of "truedefault" : c.trueDefault = e.value
of "falsedefault": c.falseDefault = e.value
of "trueDefaultStr" : c.trueDefaultStr = e.value
of "falseDefaultStr": c.falseDefaultStr = e.value
of "wrapDoc" : c.wrapDoc = e.value.parseInt
of "wrapTable" : c.wrapTable = e.value.parseInt
else:
Expand Down
4 changes: 2 additions & 2 deletions cligen/clCfgToml.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ proc apply(c: var ClCfg, cfgFile: string, plain=false) =
for tok in v2.getElems().mapIt(it.getStr()): c.hTabCols.add parseEnum[ClHelpCol](tok)
of "nohelphelp", "skiphelphelp": c.noHelpHelp = v2.getBool()
of "minstrquoting": c.minStrQuoting = v2.getBool()
of "truedefault" : c.trueDefault = v2.getStr()
of "falsedefault": c.falseDefault = v2.getStr()
of "trueDefaultStr" : c.trueDefaultStr = v2.getStr()
of "falseDefaultStr": c.falseDefaultStr = v2.getStr()
of "wrapDoc" : c.wrapDoc = v2.getInt()
of "wrapTable" : c.wrapTable = v2.getInt()
else:
Expand Down
2 changes: 1 addition & 1 deletion test/Version.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ when isMainModule:
else:
clCfg.version = "1.5"
clCfg.minStrQuoting = true # OR: [layout]minStrQuoting=true; "h i" gets ""s
clCfg.falseDefault = "" # OR: [layout]falseDefault = ""
clCfg.falseDefaultStr = "" # OR: [layout]falseDefaultStr = ""
when defined(versionShort):
dispatch(demo, short = { "version": 'V' })
else:
Expand Down

0 comments on commit 2dfb587

Please sign in to comment.