From 1dab585a267e50f4bb46f3bf6aa48a4aa8e2b0e1 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Fri, 17 Nov 2023 11:29:14 +0200 Subject: [PATCH] =?UTF-8?q?Added=20new=20command=20line=20option=20`--info?= =?UTF-8?q?:X`=20to=20nimsuggest=20for=20obtaining=20=E2=80=A6=20(#22942)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …information. (#22940) `--info:protocolVer` returns the highest nimsuggest protocol version that is supported (currently, it's version 3). `--info:nimVer` returns the Nim compiler version that nimsuggest uses internally. Note that you can obtain the Nim compiler version via `nimsuggest -v`, but that requires parsing the output, which looks like this: ``` Nim Compiler Version 2.1.1 [Linux: amd64] Compiled at 2023-11-14 Copyright (c) 2006-2023 by Andreas Rumpf git hash: 47ddfeca5247dce992becd734d1ae44e621207b8 active boot switches: -d:release -d:danger --gc:markAndSweep ``` `--info:nimVer` will return just: ``` 2.1.1 ``` (cherry picked from commit d0cc02dfc439d14bfadd4e5ac3a7855fe8d8e417) --- nimsuggest/nimsuggest.nim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 5d2c8cbb17..90f3bf0442 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -35,6 +35,7 @@ when defined(windows): else: import posix +const HighestSuggestProtocolVersion = 3 const DummyEof = "!EOF!" const Usage = """ Nimsuggest - Tool to give every editor IDE like capabilities for Nim @@ -53,6 +54,9 @@ Options: --v1 use version 1 of the protocol; for backwards compatibility --v2 use version 2(default) of the protocol --v3 use version 3 of the protocol + --info:X information + --info:nimVer return the Nim compiler version that nimsuggest uses internally + --info:protocolVer return the newest protocol version that is supported --refresh perform automatic refreshes to keep the analysis precise --maxresults:N limit the number of suggestions to N --tester implies --stdin and outputs a line @@ -637,6 +641,16 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string; conf: ConfigRef) = of "v1": conf.suggestVersion = 1 of "v2": conf.suggestVersion = 0 of "v3": conf.suggestVersion = 3 + of "info": + case p.val.normalize + of "protocolver": + stdout.writeLine(HighestSuggestProtocolVersion) + quit 0 + of "nimver": + stdout.writeLine(system.NimVersion) + quit 0 + else: + processSwitch(pass, p, conf) of "tester": gMode = mstdin gEmitEof = true