aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Options.hs
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2010-05-14 20:24:32 +0000
committerDavid Waern <david.waern@gmail.com>2010-05-14 20:24:32 +0000
commit25efba7ea3721264c56ca0f8a57dd166080c7eed (patch)
tree14aa0d080d1270d7bc180814846c9b445947f506 /src/Haddock/Options.hs
parent2203b2faada1fd7a7370d7298b63703094da42ef (diff)
Move some more flag functions to Haddock.Options
Diffstat (limited to 'src/Haddock/Options.hs')
-rw-r--r--src/Haddock/Options.hs29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/Haddock/Options.hs b/src/Haddock/Options.hs
index 7fdb7a35..de8191c7 100644
--- a/src/Haddock/Options.hs
+++ b/src/Haddock/Options.hs
@@ -23,12 +23,15 @@ module Haddock.Options (
optCssFile,
optSourceUrls,
optWikiUrls,
+ optDumpInterfaceFile,
+ verbosity,
ghcFlags,
ifacePairs
) where
import Data.Maybe
+import Distribution.Verbosity
import Haddock.Utils
import Haddock.Types
import System.Console.GetOpt
@@ -209,19 +212,31 @@ optWikiUrls flags =
,listToMaybe [str | Flag_WikiEntityURL str <- flags])
+optDumpInterfaceFile :: [Flag] -> Maybe FilePath
+optDumpInterfaceFile flags = optLast [ str | Flag_DumpInterface str <- flags ]
+
+
+verbosity :: [Flag] -> Verbosity
+verbosity flags =
+ case [ str | Flag_Verbosity str <- flags ] of
+ [] -> normal
+ x:_ -> case parseVerbosity x of
+ Left e -> throwE e
+ Right v -> v
+
+
ghcFlags :: [Flag] -> [String]
ghcFlags flags = [ option | Flag_OptGhc option <- flags ]
ifacePairs :: [Flag] -> [(FilePath, FilePath)]
ifacePairs flags = [ parseIfaceOption s | Flag_ReadInterface s <- flags ]
-
-
-parseIfaceOption :: String -> (FilePath, FilePath)
-parseIfaceOption s =
- case break (==',') s of
- (fpath,',':file) -> (fpath, file)
- (file, _) -> ("", file)
+ where
+ parseIfaceOption :: String -> (FilePath, FilePath)
+ parseIfaceOption str =
+ case break (==',') str of
+ (fpath, ',':file) -> (fpath, file)
+ (file, _) -> ("", file)
-- | Like 'listToMaybe' but returns the last element instead of the first.