Fix #386, ghc-mod version should not check cabal configure

This commit is contained in:
Daniel Gröber 2014-10-18 18:57:19 +02:00
parent 6e92f28f43
commit dbe66cbaa3

View File

@ -323,9 +323,13 @@ main = handler $ do
| otherwise -> do | otherwise -> do
let (globalOptions,cmdArgs) = parseGlobalArgs args let (globalOptions,cmdArgs) = parseGlobalArgs args
(res, _) <- runGhcModT globalOptions $ commands cmdArgs res <- simpleCommands cmdArgs
case res of putStr =<< case res of
Right s -> putStr s Just s -> return s
Nothing -> do
(res',_) <- runGhcModT globalOptions $ ghcCommands cmdArgs
case res' of
Right s -> return s
Left e -> exitError $ render (gmeDoc e) Left e -> exitError $ render (gmeDoc e)
-- Obtain ghc options by letting ourselfs be executed by -- Obtain ghc options by letting ourselfs be executed by
@ -339,14 +343,19 @@ main = handler $ do
-- rawSystem "cabal" cabalArgs >>= exitWith -- rawSystem "cabal" cabalArgs >>= exitWith
commands :: IOish m => [String] -> GhcModT m String simpleCommands :: [String] -> IO (Maybe String)
commands [] = fatalError "No command given (try --help)\n" simpleCommands [] = return Nothing
commands (cmd:args) = fn args simpleCommands (cmd:_) = return $ case cmd of
_ | cmd == "help" || cmd == "--help" -> Just usage
"version" -> Just progVersion
_ -> Nothing
ghcCommands :: IOish m => [String] -> GhcModT m String
ghcCommands [] = fatalError "No command given (try --help)\n"
ghcCommands (cmd:args) = fn args
where where
fn = case cmd of fn = case cmd of
_ | cmd == "list" || cmd == "modules" -> modulesCmd _ | cmd == "list" || cmd == "modules" -> modulesCmd
_ | cmd == "help" || cmd == "--help" -> const $ return usage
"version" -> const $ return progVersion
"lang" -> languagesCmd "lang" -> languagesCmd
"flag" -> flagsCmd "flag" -> flagsCmd
"browse" -> browseCmd "browse" -> browseCmd