Merge branch 'master' of github.com:kazu-yamamoto/ghc-mod into post-command-hook

This commit is contained in:
Kazu Yamamoto 2012-04-10 09:38:12 +09:00
commit 2ce8b64284
3 changed files with 17 additions and 4 deletions

View File

@ -17,16 +17,24 @@ import Types
modifyOptions :: Options -> IO Options
modifyOptions opts = found ||> notFound
where
found = addPath opts <$> findCabalDev
found = do
path <- findCabalDev (sandbox opts)
return $ addPath opts path
notFound = return opts
findCabalDev :: IO String
findCabalDev = getCurrentDirectory >>= searchIt . splitPath
findCabalDev :: Maybe String -> IO FilePath
findCabalDev (Just path) = do
a <- doesDirectoryExist path
if a then
findConf path
else
findCabalDev Nothing
findCabalDev Nothing = getCurrentDirectory >>= searchIt . splitPath
addPath :: Options -> String -> Options
addPath orig_opts path = do
let orig_ghcopt = ghcOpts orig_opts
orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path] }
orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path, "-no-user-package-conf"] }
searchIt :: [FilePath] -> IO FilePath
searchIt [] = throwIO $ userError "Not found"

View File

@ -57,6 +57,9 @@ argspec = [ Option "l" ["tolisp"]
, Option "o" ["operators"]
(NoArg (\opts -> opts { operators = True }))
"print operators, too"
, Option "s" ["sandbox"]
(ReqArg (\s opts -> opts { sandbox = Just s }) "path")
"specify cabal-dev sandbox (default 'cabal-dev`)"
]
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])

View File

@ -10,6 +10,7 @@ data Options = Options {
, ghcOpts :: [String]
, operators :: Bool
, expandSplice :: Bool
, sandbox :: Maybe String
}
defaultOptions :: Options
@ -19,6 +20,7 @@ defaultOptions = Options {
, ghcOpts = []
, operators = False
, expandSplice = False
, sandbox = Nothing
}
----------------------------------------------------------------