@@ -124,12 +124,12 @@ import Text.Printf (printf)
124124
125125data Command
126126 = Check [FilePath ] -- ^ Typecheck some paths and print diagnostics. Exit code is the number of failures
127- | Db { projectRoot :: FilePath , hieOptions :: HieDb. Options , hieCommand :: HieDb. Command}
127+ | Db { hieOptions :: HieDb. Options , hieCommand :: HieDb. Command}
128128 -- ^ Run a command in the hiedb
129129 | LSP -- ^ Run the LSP server
130130 | PrintExtensionSchema
131131 | PrintDefaultConfig
132- | Custom { projectRoot :: FilePath , ideCommand :: IdeCommand IdeState } -- ^ User defined
132+ | Custom { ideCommand :: IdeCommand IdeState } -- ^ User defined
133133 deriving Show
134134
135135
@@ -144,7 +144,7 @@ isLSP _ = False
144144commandP :: IdePlugins IdeState -> Parser Command
145145commandP plugins =
146146 hsubparser(command " typecheck" (info (Check <$> fileCmd) fileInfo)
147- <> command " hiedb" (info (Db " . " <$> HieDb. optParser " " True <*> HieDb. cmdParser <**> helper) hieInfo)
147+ <> command " hiedb" (info (Db <$> HieDb. optParser " " True <*> HieDb. cmdParser <**> helper) hieInfo)
148148 <> command " lsp" (info (pure LSP <**> helper) lspInfo)
149149 <> command " vscode-extension-schema" extensionSchemaCommand
150150 <> command " generate-default-config" generateDefaultConfigCommand
@@ -163,13 +163,14 @@ commandP plugins =
163163 (fullDesc <> progDesc " Print config supported by the server with default values" )
164164
165165 pluginCommands = mconcat
166- [ command (T. unpack pId) (Custom " . " <$> p)
166+ [ command (T. unpack pId) (Custom <$> p)
167167 | (PluginId pId, PluginDescriptor {pluginCli = Just p}) <- ipMap plugins
168168 ]
169169
170170
171171data Arguments = Arguments
172- { argsOTMemoryProfiling :: Bool
172+ { argsProjectRoot :: Maybe FilePath
173+ , argsOTMemoryProfiling :: Bool
173174 , argCommand :: Command
174175 , argsLogger :: IO Logger
175176 , argsRules :: Rules ()
@@ -191,7 +192,8 @@ instance Default Arguments where
191192
192193defaultArguments :: Priority -> Arguments
193194defaultArguments priority = Arguments
194- { argsOTMemoryProfiling = False
195+ { argsProjectRoot = Nothing
196+ , argsOTMemoryProfiling = False
195197 , argCommand = LSP
196198 , argsLogger = stderrLogger priority
197199 , argsRules = mainRule def >> action kick
@@ -319,7 +321,7 @@ defaultMain Arguments{..} = flip withHeapStats fun =<< argsLogger
319321 hieChan
320322 dumpSTMStats
321323 Check argFiles -> do
322- dir <- IO. getCurrentDirectory
324+ dir <- maybe IO. getCurrentDirectory return argsProjectRoot
323325 dbLoc <- getHieDbLoc dir
324326 runWithDb logger dbLoc $ \ hiedb hieChan -> do
325327 -- GHC produces messages with UTF8 in them, so make sure the terminal doesn't error
@@ -382,17 +384,19 @@ defaultMain Arguments{..} = flip withHeapStats fun =<< argsLogger
382384 measureMemory logger [keys] consoleObserver values
383385
384386 unless (null failed) (exitWith $ ExitFailure (length failed))
385- Db dir opts cmd -> do
386- dbLoc <- getHieDbLoc dir
387+ Db opts cmd -> do
388+ root <- maybe IO. getCurrentDirectory return argsProjectRoot
389+ dbLoc <- getHieDbLoc root
387390 hPutStrLn stderr $ " Using hiedb at: " ++ dbLoc
388- mlibdir <- setInitialDynFlags logger dir def
391+ mlibdir <- setInitialDynFlags logger root def
389392 rng <- newStdGen
390393 case mlibdir of
391394 Nothing -> exitWith $ ExitFailure 1
392395 Just libdir -> retryOnSqliteBusy logger rng (HieDb. runCommand libdir opts{HieDb. database = dbLoc} cmd)
393396
394- Custom projectRoot (IdeCommand c) -> do
395- dbLoc <- getHieDbLoc projectRoot
397+ Custom (IdeCommand c) -> do
398+ root <- maybe IO. getCurrentDirectory return argsProjectRoot
399+ dbLoc <- getHieDbLoc root
396400 runWithDb logger dbLoc $ \ hiedb hieChan -> do
397401 vfs <- makeVFSHandle
398402 sessionLoader <- loadSessionWithOptions argsSessionLoadingOptions " ."
0 commit comments