summary refs log tree commit diff stats
path: root/nimsuggest/nimsuggest.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-03-14 12:28:15 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-03-14 12:28:15 +0100
commitf7d760cb94ffef99b596d167fc517284e5a6a757 (patch)
treebb6177e4731a54e87774fe6b5ab70f13e843cc30 /nimsuggest/nimsuggest.nim
parentb414806e66efbf37c8e7edf832cb9a266f433d60 (diff)
downloadNim-f7d760cb94ffef99b596d167fc517284e5a6a757.tar.gz
nimsuggest: when invoked with a directory, detect the main nim file on its own
Diffstat (limited to 'nimsuggest/nimsuggest.nim')
-rw-r--r--nimsuggest/nimsuggest.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim
index 2cf19925c..0b66dfb40 100644
--- a/nimsuggest/nimsuggest.nim
+++ b/nimsuggest/nimsuggest.nim
@@ -556,7 +556,13 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
         suggestMaxResults = parseInt(p.val)
       else: processSwitch(pass, p)
     of cmdArgument:
-      options.gProjectName = unixToNativePath(p.key)
+      let a = unixToNativePath(p.key)
+      if dirExists(a) and not fileExists(a.addFileExt("nim")):
+        options.gProjectName = findProjectNimFile(a)
+        # don't make it worse, report the error the old way:
+        if options.gProjectName.len == 0: options.gProjectName = a
+      else:
+        options.gProjectName = a
       # if processArgument(pass, p, argsCount): break
 
 proc handleCmdLine(cache: IdentCache; config: ConfigRef) =