[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:57:49 UTC 2010
The following commit has been merged in the master branch:
commit e8655ced7cd43b99af237e78bfe6653f59a36173
Author: John Goerzen <jgoerzen at complete.org>
Date: Mon Apr 18 23:24:20 2005 +0100
New standard option utilities
diff --git a/MissingH/GetOpt.hs b/MissingH/GetOpt.hs
index c5d2576..932535d 100644
--- a/MissingH/GetOpt.hs
+++ b/MissingH/GetOpt.hs
@@ -32,7 +32,10 @@ Utilities for command-line parsing, including wrappers around
the standard System.Console.GetOpt module.
-}
module MissingH.GetOpt (parseCmdLine,
- validateCmdLine
+ validateCmdLine,
+ StdOption,
+ stdRequired,
+ stdOptional
)
where
import System.Console.GetOpt
@@ -71,3 +74,21 @@ validateCmdLine order options header func =
Nothing -> return res
Just error -> ioError (userError (concat [error] ++
usageInfo header options))
+
+{- | A type to standardize some common uses of GetOpt.
+
+The first component of the tuple is the long name of the option.
+
+The second component is empty if there is no arg, or has the arg otherwise. -}
+type StdOption = (String, String)
+
+{- | Handle a required argument. -}
+stdRequired :: String -- ^ Name of arg
+ -> String -> StdOption
+stdRequired name value = (name, value)
+
+{- | Handle an optional argument. -}
+stdOptional :: String -- ^ Name of arg
+ -> Maybe String -> StdOption
+stdOptional name Nothing = (name, "")
+stdOptional name (Just x) = (name, x)
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list