mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-03 12:34:44 +00:00
Allow strings for -- in config.nims (#16934)
This commit is contained in:
@@ -159,16 +159,29 @@ proc toDll*(filename: string): string =
|
|||||||
|
|
||||||
proc strip(s: string): string =
|
proc strip(s: string): string =
|
||||||
var i = 0
|
var i = 0
|
||||||
while s[i] in {' ', '\c', '\L'}: inc i
|
while s[i] in {' ', '\c', '\n'}: inc i
|
||||||
result = s.substr(i)
|
result = s.substr(i)
|
||||||
|
if result[0] == '"' and result[^1] == '"':
|
||||||
|
result = result[1..^2]
|
||||||
|
|
||||||
template `--`*(key, val: untyped) =
|
template `--`*(key, val: untyped) =
|
||||||
## A shortcut for ``switch(astToStr(key), astToStr(val))``.
|
## A shortcut for `switch <#switch,string,string>`_
|
||||||
switch(astToStr(key), strip astToStr(val))
|
## Example:
|
||||||
|
##
|
||||||
|
## .. code-block:: nim
|
||||||
|
##
|
||||||
|
## --path:somePath # same as switch("path", "somePath")
|
||||||
|
## --path:"someOtherPath" # same as switch("path", "someOtherPath")
|
||||||
|
switch(strip(astToStr(key)), strip(astToStr(val)))
|
||||||
|
|
||||||
template `--`*(key: untyped) =
|
template `--`*(key: untyped) =
|
||||||
## A shortcut for ``switch(astToStr(key)``.
|
## A shortcut for `switch <#switch,string>`_
|
||||||
switch(astToStr(key), "")
|
## Example:
|
||||||
|
##
|
||||||
|
## .. code-block:: nim
|
||||||
|
##
|
||||||
|
## --listCmd # same as switch("listCmd")
|
||||||
|
switch(strip(astToStr(key)))
|
||||||
|
|
||||||
type
|
type
|
||||||
ScriptMode* {.pure.} = enum ## Controls the behaviour of the script.
|
ScriptMode* {.pure.} = enum ## Controls the behaviour of the script.
|
||||||
|
|||||||
Reference in New Issue
Block a user