From c3b95cbd2c944512585b843df7f0920894cf16ae Mon Sep 17 00:00:00 2001 From: daylin <47667941+daylinmorgan@users.noreply.github.com> Date: Sat, 30 Sep 2023 07:53:09 -0500 Subject: [PATCH] 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). --- doc/nims.md | 2 ++ lib/system/nimscript.nim | 1 + 2 files changed, 3 insertions(+) diff --git a/doc/nims.md b/doc/nims.md index 01cdf47c35..42cc6e124d 100644 --- a/doc/nims.md +++ b/doc/nims.md @@ -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 diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim index a2c897b04b..bdf6145a11 100644 --- a/lib/system/nimscript.nim +++ b/lib/system/nimscript.nim @@ -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)))