@@ -98,8 +98,10 @@ import Text.Printf (printf)
98
98
99
99
data Command
100
100
= Check [FilePath ] -- ^ Typecheck some paths and print diagnostics. Exit code is the number of failures
101
- | Db FilePath HieDb. Options HieDb. Command -- ^ Run a command in the hiedb
102
- | Index [FilePath ] -- ^ Index all the targets and print the path to the database
101
+ | Index { projectRoot :: FilePath , targetsToLoad :: [FilePath ]}
102
+ -- ^ Index all the targets and print the path to the database
103
+ | Db { projectRoot :: FilePath , hieOptions :: HieDb. Options , hieCommand :: HieDb. Command}
104
+ -- ^ Run a command in the hiedb
103
105
| LSP -- ^ Run the LSP server
104
106
deriving Show
105
107
@@ -113,10 +115,10 @@ isLSP _ = False
113
115
114
116
commandP :: Parser Command
115
117
commandP = hsubparser (command " typecheck" (info (Check <$> fileCmd) fileInfo)
116
- <> command " hiedb" (info (Db " ." <$> HieDb. optParser " " True <*> HieDb. cmdParser <**> helper) hieInfo)
117
- <> command " index" (info (Index <$> fileCmd) indexInfo)
118
- <> command " lsp" (info (pure LSP <**> helper) lspInfo)
119
- )
118
+ <> command " hiedb" (info (Db " ." <$> HieDb. optParser " " True <*> HieDb. cmdParser <**> helper) hieInfo)
119
+ <> command " index" (info (Index " . " <$> fileCmd) indexInfo)
120
+ <> command " lsp" (info (pure LSP <**> helper) lspInfo)
121
+ )
120
122
where
121
123
fileCmd = many (argument str (metavar " FILES/DIRS..." ))
122
124
lspInfo = fullDesc <> progDesc " Start talking to an LSP client"
@@ -294,9 +296,9 @@ defaultMain Arguments{..} = do
294
296
measureMemory logger [keys] consoleObserver valuesRef
295
297
296
298
unless (null failed) (exitWith $ ExitFailure (length failed))
297
- Index argFiles -> do
298
- dbLoc <- getHieDbLoc " . "
299
- files <- expandFiles (argFiles ++ [" . " | null argFiles ])
299
+ Index { .. } -> do
300
+ dbLoc <- getHieDbLoc projectRoot
301
+ files <- expandFiles (targetsToLoad ++ [projectRoot | null targetsToLoad ])
300
302
runWithDb dbLoc $ \ hiedb hieChan -> do
301
303
vfs <- makeVFSHandle
302
304
sessionLoader <- loadSessionWithOptions argsSessionLoadingOptions " ."
0 commit comments