diff options
author | alaviss <alaviss@users.noreply.github.com> | 2019-10-11 14:55:15 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-10-11 09:55:15 +0200 |
commit | eeffa0163fba932f5e0a16023ef3c4b833b36358 (patch) | |
tree | e0ad594f47149b5f1defef17c7862da3a08d7648 /nimsuggest/nimsuggest.nim | |
parent | 7cf3395d857d2e05fb3a83dc67173a69c828807f (diff) | |
download | Nim-eeffa0163fba932f5e0a16023ef3c4b833b36358.tar.gz |
nimsuggest: add option to force finding the project file (#12409)
Diffstat (limited to 'nimsuggest/nimsuggest.nim')
-rw-r--r-- | nimsuggest/nimsuggest.nim | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index aa45a64e9..26cb0ce31 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -48,6 +48,7 @@ Options: --maxresults:N limit the number of suggestions to N --tester implies --stdin and outputs a line '""" & DummyEof & """' for the tester + --find attempts to find the project file of the current project The server then listens to the connection and takes line-based commands. @@ -549,6 +550,7 @@ proc mainCommand(graph: ModuleGraph) = proc processCmdLine*(pass: TCmdLinePass, cmd: string; conf: ConfigRef) = var p = parseopt.initOptParser(cmd) + var findProject = false while true: parseopt.next(p) case p.kind @@ -594,6 +596,8 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string; conf: ConfigRef) = gRefresh = true of "maxresults": conf.suggestMaxResults = parseInt(p.val) + of "find": + findProject = true else: processSwitch(pass, p, conf) of cmdArgument: let a = unixToNativePath(p.key) @@ -602,7 +606,12 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string; conf: ConfigRef) = # don't make it worse, report the error the old way: if conf.projectName.len == 0: conf.projectName = a else: - conf.projectName = a + if findProject: + conf.projectName = findProjectNimFile(conf, a.parentDir()) + if conf.projectName.len == 0: + conf.projectName = a + else: + conf.projectName = a # if processArgument(pass, p, argsCount): break proc handleCmdLine(cache: IdentCache; conf: ConfigRef) = |