`processArguments` now can have alternate OptParser instead of fixed one
the `processArguments` now have overloaded proc, one with opt param and one without. the OptParser now can be passed to `opt` param. this is useful in scenario where in test code we need to simulate something without using real command line arguments.
This commit is contained in:
parent
6049073c69
commit
e6d7d6188c
|
@ -977,7 +977,7 @@ LOGGING AND DEBUGGING OPTIONS:
|
||||||
]
|
]
|
||||||
|
|
||||||
when declared(os.paramCount): # not available with `--app:lib`
|
when declared(os.paramCount): # not available with `--app:lib`
|
||||||
proc processArguments*(msg: var string): ConfigStatus =
|
proc processArguments*(msg: var string, opt: var OptParser): ConfigStatus =
|
||||||
## Process command line argument and update `NimbusConfiguration`.
|
## Process command line argument and update `NimbusConfiguration`.
|
||||||
let config = getConfiguration()
|
let config = getConfiguration()
|
||||||
|
|
||||||
|
@ -994,7 +994,6 @@ when declared(os.paramCount): # not available with `--app:lib`
|
||||||
# The same trick is done to discPort
|
# The same trick is done to discPort
|
||||||
config.net.discPort = 0
|
config.net.discPort = 0
|
||||||
|
|
||||||
var opt = initOptParser()
|
|
||||||
var length = 0
|
var length = 0
|
||||||
for kind, key, value in opt.getopt():
|
for kind, key, value in opt.getopt():
|
||||||
result = Error
|
result = Error
|
||||||
|
@ -1033,6 +1032,10 @@ when declared(os.paramCount): # not available with `--app:lib`
|
||||||
if config.net.discPort == 0:
|
if config.net.discPort == 0:
|
||||||
config.net.discPort = config.net.bindPort
|
config.net.discPort = config.net.bindPort
|
||||||
|
|
||||||
|
proc processArguments*(msg: var string): ConfigStatus =
|
||||||
|
var opt = initOptParser()
|
||||||
|
processArguments(msg, opt)
|
||||||
|
|
||||||
proc processConfiguration*(pathname: string): ConfigStatus =
|
proc processConfiguration*(pathname: string): ConfigStatus =
|
||||||
## Process configuration file `pathname` and update `NimbusConfiguration`.
|
## Process configuration file `pathname` and update `NimbusConfiguration`.
|
||||||
result = Success
|
result = Success
|
||||||
|
|
Loading…
Reference in New Issue