docs: add another switch example for nimscript (#22772)

I couldn't find any documentation on the syntax for --hint:X:on|off with
`nimscript` except in [this old forum
post](https://forum.nim-lang.org/t/8526#55236).
This commit is contained in:
daylin
2023-09-30 07:53:09 -05:00
committed by GitHub
parent b2ca6bedae
commit c3b95cbd2c
2 changed files with 3 additions and 0 deletions

View File

@@ -124,6 +124,8 @@ Here are few examples of using the `switch` proc:
switch("define", "release")
# command-line: --forceBuild
switch("forceBuild")
# command-line: --hint[Conf]:off or --hint:Conf:off
switch("hint", "[Conf]:off")
```
NimScripts also support `--`:option: templates for convenience, which look

View File

@@ -161,6 +161,7 @@ template `--`*(key, val: untyped) =
## ```nim
## --path:somePath # same as switch("path", "somePath")
## --path:"someOtherPath" # same as switch("path", "someOtherPath")
## --hint:"[Conf]:off" # same as switch("hint", "[Conf]:off")
## ```
switch(strip(astToStr(key)), strip(astToStr(val)))