Commit a28731b3 authored by Jan Stolarek's avatar Jan Stolarek Committed by Edward Z. Yang

Add --show-options to list all flags (Fixes #7843)

parent cfe92a8f
......@@ -35,7 +35,10 @@ module StaticFlags (
addOpt, removeOpt, v_opt_C_ready,
-- Saving/restoring globals
saveStaticFlagGlobals, restoreStaticFlagGlobals
saveStaticFlagGlobals, restoreStaticFlagGlobals,
-- For options autocompletion
flagsStatic, flagsStaticNames
) where
#include "HsVersions.h"
......@@ -139,9 +142,13 @@ flagsStatic = [
]
isStaticFlag :: String -> Bool
isStaticFlag f =
f `elem` [
isStaticFlag f = f `elem` flagsStaticNames
flagsStaticNames :: [String]
flagsStaticNames = [
"fdicts-strict",
"fno-state-hack",
"fno-opt-coercion",
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment