Skip to content

Commit

Permalink
Declare empty commandLineParams if the standard one is not declared.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitvly committed Jan 25, 2024
1 parent 1bee430 commit d8871f9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions confutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -884,21 +884,15 @@ func constructEnvKey*(prefix: string, key: string): string {.raises: [].} =
except ValueError as err:
raiseAssert "strformat.`&` failed: " & err.msg

var getCLIParams*: proc(): seq[TaintedString]

# On Posix there is no portable way to get the command
# line from a DLL and thus the proc isn't defined in this environment.
# See https://nim-lang.org/docs/os.html#commandLineParams
when declared(commandLineParams):
getCLIParams = commandLineParams
else:
getCLIParams = proc(): seq[TaintedString] =
var emptyTaintedSeq: seq[TaintedString]
return emptyTaintedSeq
when not declared(commandLineParams):
proc commandLineParams(): seq[string] = discard

proc loadImpl[C, SecondarySources](
Configuration: typedesc[C],
cmdLine = getCLIParams(),
cmdLine = commandLineParams(),
version = "",
copyrightBanner = "",
printUsage = true,
Expand Down Expand Up @@ -1180,7 +1174,7 @@ proc loadImpl[C, SecondarySources](

template load*(
Configuration: type,
cmdLine = getCLIParams(),
cmdLine = commandLineParams(),
version = "",
copyrightBanner = "",
printUsage = true,
Expand Down

0 comments on commit d8871f9

Please sign in to comment.