supporting "lang" command.

This commit is contained in:
Kazu Yamamoto 2010-04-02 14:40:06 +09:00
parent bb07f52a8a
commit 4202ca1ea2
2 changed files with 16 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import Check
import Control.Exception hiding (try)
import List
import Param
import Lang
import Prelude hiding (catch)
import System.Console.GetOpt
import System.Environment (getArgs)
@ -63,6 +64,7 @@ main = flip catch handler $ do
"browse" -> browseModule opt (cmdArg !! 1)
"list" -> listModules opt
"check" -> checkSyntax opt (cmdArg !! 1)
"lang" -> listLanguages opt
_ -> error usage
putStr res
where

14
Lang.hs Normal file
View File

@ -0,0 +1,14 @@
module Lang where
import Control.Applicative
import Param
import System.IO
import System.Process
listLanguages :: Options -> IO String
listLanguages opt = convert opt . lines <$> getLangs opt
getLangs :: Options -> IO String
getLangs opt = do
(_,hout,_,_) <- runInteractiveProcess (ghc opt) ["--supported-languages"] Nothing Nothing
hGetContents hout