aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockUtil.hs
diff options
context:
space:
mode:
authorpanne <unknown>2003-08-27 07:50:03 +0000
committerpanne <unknown>2003-08-27 07:50:03 +0000
commite657726555e1e7a494c5a759547b1d102d54c236 (patch)
tree0ccc6b3c9a58224b50f3c7bee186a9bdf5f3e008 /src/HaddockUtil.hs
parent5d156a914ad37f6dc0f412acd527ee069b1151fa (diff)
[haddock @ 2003-08-27 07:50:02 by panne]
* Made -D a short option for --dump-interface. * Made -m a short option for --ms-help. * Made -n a short option for --no-implicit-prelude. * Made -c a short option for --css. * Removed DocBook options from executable (they didn't do anything), but mark them as reserved in the docs. Note that the short option for DocBook output is now -S (from SGML) instead of -d. The latter is now a short option for --debug. * The order of the Options in the documentation now matches the order printed by Haddock itself. Note: Although changing the names of options is often a bad idea, I'd really like to make the options for the programs in fptools more consistent and compatible to the ones used in common GNU programs.
Diffstat (limited to 'src/HaddockUtil.hs')
-rw-r--r--src/HaddockUtil.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/HaddockUtil.hs b/src/HaddockUtil.hs
index 9804fb6e..20d86b79 100644
--- a/src/HaddockUtil.hs
+++ b/src/HaddockUtil.hs
@@ -18,7 +18,7 @@ module HaddockUtil (
moduleHtmlFile,
-- * Miscellaneous utilities
- die, dieMsg, mapSnd, mapMaybeM,
+ getProgramName, bye, die, dieMsg, mapSnd, mapMaybeM,
-- * HTML cross reference mapping
html_xrefs_ref, html_xrefs,
@@ -26,7 +26,7 @@ module HaddockUtil (
import HsSyn
-import List ( intersect )
+import List ( intersect, isSuffixOf )
import Maybe
import IO ( hPutStr, stderr )
import System
@@ -261,11 +261,20 @@ moduleHtmlFile dir mod0 = dir ++ pathSeparator : mod0 ++ ".html"
-----------------------------------------------------------------------------
-- misc.
+getProgramName :: IO String
+getProgramName = liftM (`withoutSuffix` ".bin") getProgName
+ where str `withoutSuffix` suff
+ | suff `isSuffixOf` str = take (length str - length suff) str
+ | otherwise = str
+
+bye :: String -> IO a
+bye s = putStr s >> exitWith ExitSuccess
+
die :: String -> IO a
die s = hPutStr stderr s >> exitWith (ExitFailure 1)
dieMsg :: String -> IO a
-dieMsg s = getProgName >>= \prog -> die (prog ++ ": " ++ s)
+dieMsg s = getProgramName >>= \prog -> die (prog ++ ": " ++ s)
mapSnd :: (b -> c) -> [(a,b)] -> [(a,c)]
mapSnd _ [] = []