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