ghc-mod list
should take care of sandboxes
This commit is contained in:
parent
169069f623
commit
67166a4d75
@ -1,6 +1,7 @@
|
|||||||
module Language.Haskell.GhcMod.List (listModules, listMods) where
|
module Language.Haskell.GhcMod.List (listModules, listMods) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
|
import Control.Monad (void)
|
||||||
import Data.List
|
import Data.List
|
||||||
import GHC
|
import GHC
|
||||||
import Language.Haskell.GhcMod.GHCApi
|
import Language.Haskell.GhcMod.GHCApi
|
||||||
@ -11,13 +12,13 @@ import UniqFM
|
|||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
-- | Listing installed modules.
|
-- | Listing installed modules.
|
||||||
listModules :: Options -> IO String
|
listModules :: Options -> Cradle -> IO String
|
||||||
listModules opt = convert opt . nub . sort <$> withGHCDummyFile (listMods opt)
|
listModules opt cradle = convert opt . nub . sort <$> withGHCDummyFile (listMods opt cradle)
|
||||||
|
|
||||||
-- | Listing installed modules.
|
-- | Listing installed modules.
|
||||||
listMods :: Options -> Ghc [String]
|
listMods :: Options -> Cradle -> Ghc [String]
|
||||||
listMods opt = do
|
listMods opt cradle = do
|
||||||
initializeFlags opt
|
void $ initializeFlagsWithCradle opt cradle [] False
|
||||||
getExposedModules <$> getSessionDynFlags
|
getExposedModules <$> getSessionDynFlags
|
||||||
where
|
where
|
||||||
getExposedModules = map moduleNameString
|
getExposedModules = map moduleNameString
|
||||||
|
@ -97,7 +97,7 @@ main = flip catches handlers $ do
|
|||||||
else throw (TooManyArguments cmdArg0)
|
else throw (TooManyArguments cmdArg0)
|
||||||
res <- case cmdArg0 of
|
res <- case cmdArg0 of
|
||||||
"browse" -> concat <$> mapM (browseModule opt) remainingArgs
|
"browse" -> concat <$> mapM (browseModule opt) remainingArgs
|
||||||
"list" -> listModules opt
|
"list" -> listModules opt cradle
|
||||||
"check" -> checkSyntax opt cradle remainingArgs
|
"check" -> checkSyntax opt cradle remainingArgs
|
||||||
"expand" -> checkSyntax opt { expandSplice = True } cradle remainingArgs
|
"expand" -> checkSyntax opt { expandSplice = True } cradle remainingArgs
|
||||||
"debug" -> nArgs 1 $ debugInfo opt cradle cmdArg1
|
"debug" -> nArgs 1 $ debugInfo opt cradle cmdArg1
|
||||||
@ -107,7 +107,7 @@ main = flip catches handlers $ do
|
|||||||
"lang" -> listLanguages opt
|
"lang" -> listLanguages opt
|
||||||
"flag" -> listFlags opt
|
"flag" -> listFlags opt
|
||||||
"boot" -> do
|
"boot" -> do
|
||||||
mods <- listModules opt
|
mods <- listModules opt cradle
|
||||||
langs <- listLanguages opt
|
langs <- listLanguages opt
|
||||||
flags <- listFlags opt
|
flags <- listFlags opt
|
||||||
pre <- concat <$> mapM (browseModule opt) preBrowsedModules
|
pre <- concat <$> mapM (browseModule opt) preBrowsedModules
|
||||||
|
@ -8,5 +8,6 @@ spec :: Spec
|
|||||||
spec = do
|
spec = do
|
||||||
describe "listModules" $ do
|
describe "listModules" $ do
|
||||||
it "lists up module names" $ do
|
it "lists up module names" $ do
|
||||||
modules <- lines <$> listModules defaultOptions
|
cradle <- findCradle
|
||||||
|
modules <- lines <$> listModules defaultOptions cradle
|
||||||
modules `shouldContain` ["Data.Map"]
|
modules `shouldContain` ["Data.Map"]
|
||||||
|
Loading…
Reference in New Issue
Block a user