diff options
author | Jan Stolarek <jan.stolarek@p.lodz.pl> | 2013-06-04 10:28:32 +0200 |
---|---|---|
committer | Edward Z. Yang <ezyang@mit.edu> | 2013-06-06 12:29:35 -0700 |
commit | a28731b3a14ff6ef9c7dca8327d073e6ebb6b773 (patch) | |
tree | 9d09077d0307c43605c5ac8d15bb4ce44dd5761d /ghc | |
parent | cfe92a8f8482a3c863c3bddc4be894b09fb972ff (diff) | |
download | haskell-a28731b3a14ff6ef9c7dca8327d073e6ebb6b773.tar.gz |
Add --show-options to list all flags (Fixes #7843)
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/Main.hs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index f636c380b2..52a90d07e7 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -109,6 +109,7 @@ main = do ShowSupportedExtensions -> showSupportedExtensions ShowVersion -> showVersion ShowNumVersion -> putStrLn cProjectVersion + ShowOptions -> showOptions Right postStartupMode -> -- start our GHC session GHC.runGhc mbMinusB $ do @@ -371,11 +372,13 @@ data PreStartupMode = ShowVersion -- ghc -V/--version | ShowNumVersion -- ghc --numeric-version | ShowSupportedExtensions -- ghc --supported-extensions + | ShowOptions -- ghc --show-options -showVersionMode, showNumVersionMode, showSupportedExtensionsMode :: Mode +showVersionMode, showNumVersionMode, showSupportedExtensionsMode, showOptionsMode :: Mode showVersionMode = mkPreStartupMode ShowVersion showNumVersionMode = mkPreStartupMode ShowNumVersion showSupportedExtensionsMode = mkPreStartupMode ShowSupportedExtensions +showOptionsMode = mkPreStartupMode ShowOptions mkPreStartupMode :: PreStartupMode -> Mode mkPreStartupMode = Left @@ -519,6 +522,7 @@ mode_flags = , Flag "-version" (PassFlag (setMode showVersionMode)) , Flag "-numeric-version" (PassFlag (setMode showNumVersionMode)) , Flag "-info" (PassFlag (setMode showInfoMode)) + , Flag "-show-options" (PassFlag (setMode showOptionsMode)) , Flag "-supported-languages" (PassFlag (setMode showSupportedExtensionsMode)) , Flag "-supported-extensions" (PassFlag (setMode showSupportedExtensionsMode)) ] ++ @@ -693,6 +697,21 @@ showSupportedExtensions = mapM_ putStrLn supportedLanguagesAndExtensions showVersion :: IO () showVersion = putStrLn (cProjectName ++ ", version " ++ cProjectVersion) +showOptions :: IO () +showOptions = putStr (unlines availableOptions) + where + availableOptions = map ((:) '-') . filter ((>2) . length) $ + getFlagNames mode_flags ++ + getFlagNames flagsDynamic ++ + (filterUnwantedStatic . getFlagNames $ flagsStatic) ++ + flagsStaticNames + getFlagNames opts = map getFlagName opts + getFlagName (Flag name _) = name + -- this is a hack to get rid of two unwanted entries that get listed + -- as static flags. Hopefully this hack will disappear one day together + -- with static flags + filterUnwantedStatic = filter (\x -> not (x `elem` ["f", "fno-"])) + showGhcUsage :: DynFlags -> IO () showGhcUsage = showUsage False |