simple-get-opt 0.2.0 → 0.3
raw patch · 2 files changed
+8/−5 lines, 2 files
Files
- simple-get-opt.cabal +1/−1
- src/SimpleGetOpt.hs +7/−4
simple-get-opt.cabal view
@@ -1,5 +1,5 @@ name: simple-get-opt-version: 0.2.0+version: 0.3 synopsis: A simple library for processing command-line options. description: A simple library for processing command-line options.
src/SimpleGetOpt.hs view
@@ -59,6 +59,9 @@ , dumpUsage , reportUsageError , usageString++ -- * Direct interaction with GetOpt+ , specToGetOpt ) where import qualified System.Console.GetOpt as GetOpt@@ -115,8 +118,8 @@ -- The string describes the type of the argument. -opts :: OptSpec a -> [ GetOpt.OptDescr (OptSetter a) ]-opts = map convertOpt . progOptions+specToGetOpt :: OptSpec a -> [ GetOpt.OptDescr (OptSetter a) ]+specToGetOpt = map convertOpt . progOptions convertArg :: ArgDescr a -> GetOpt.ArgDescr (OptSetter a) convertArg arg =@@ -147,7 +150,7 @@ getOptsX :: OptSpec a -> IO a getOptsX os = do as <- getArgs- let (funs,files,errs) = GetOpt.getOpt GetOpt.Permute (opts os) as+ let (funs,files,errs) = GetOpt.getOpt GetOpt.Permute (specToGetOpt os) as unless (null errs) $ throwIO (GetOptException errs) let (a, errs1) = foldl addOpt (progDefaults os,[]) funs unless (null errs1) $ throwIO (GetOptException errs1)@@ -179,7 +182,7 @@ -- | A string descibing the options. usageString :: OptSpec a -> String-usageString os = GetOpt.usageInfo (params ++ "Flags:") (opts os)+usageString os = GetOpt.usageInfo (params ++ "Flags:") (specToGetOpt os) where params = case concatMap ppParam (progParamDocs os) of "" -> ""