packages feed

cmdargs 0.10.16 → 0.10.17

raw patch · 5 files changed

+25/−16 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ System.Console.CmdArgs.Explicit: processValueIO :: Mode a -> [String] -> IO a

Files

CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for CmdArgs +0.10.17+    Add processValueIO for more controlled error messages+    #529, don't include the stack trace in processValue 0.10.16     Minor improvement to error messages 0.10.15
Data/Generics/Any.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE ExistentialQuantification #-}  module Data.Generics.Any where
System/Console/CmdArgs/Explicit.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ScopedTypeVariables, CPP #-} {-|     This module constructs command lines. You may either use the helper functions     ('flagNone', 'flagOpt', 'mode' etc.) or construct the type directly. These@@ -53,7 +53,7 @@ -} module System.Console.CmdArgs.Explicit(     -- * Running command lines-    process, processArgs, processValue,+    process, processArgs, processValue, processValueIO,     -- * Constructing command lines     module System.Console.CmdArgs.Explicit.Type,     flagHelpSimple, flagHelpFormat, flagVersion, flagNumericVersion, flagsVerbosity,@@ -112,7 +112,7 @@             let var = mplus (lookup ("CMDARGS_HELPER_" ++ show (map toUpper $ head $ modeNames m ++ [nam])) env)                             (lookup "CMDARGS_HELPER" env)             case var of-                Nothing -> run =<< (if modeExpandAt m then expandArgsAt else return) =<< getArgs+                Nothing -> processValueIO m =<< (if modeExpandAt m then expandArgsAt else return) =<< getArgs                 Just cmd -> do                     res <- execute cmd m []                     case res of@@ -120,11 +120,7 @@                             hPutStrLn stderr $ "Error when running helper " ++ cmd                             hPutStrLn stderr err                             exitFailure               -                        Right args -> run args-    where-        run args = case process m args of-            Left x -> do hPutStrLn stderr x; exitFailure-            Right x -> return x+                        Right args -> processValueIO m args   readMay :: Read a => String -> Maybe a@@ -133,15 +129,28 @@                 _ -> Nothing  --- | Process a list of flags (usually obtained from @'getArgs'@ and @'expandArgsAt'@) with a mode. Displays---   an error and exits with failure if the command line fails to parse, or returns+#if __GLASGOW_HASKELL__ < 800+errorWithoutStackTrace :: String -> a+errorWithoutStackTrace = error+#endif++-- | Process a list of flags (usually obtained from @'getArgs'@ and @'expandArgsAt'@) with a mode.+--   Throws an error if the command line fails to parse, or returns --   the associated value. Implemeneted in terms of 'process'. This function --   does not take account of any environment variables that may be set --   (see 'processArgs').+--+--   If you are in 'IO' you will probably get a better user experience by calling 'processValueIO'. processValue :: Mode a -> [String] -> a processValue m xs = case process m xs of-    Left x -> error x+    Left x -> errorWithoutStackTrace x     Right x -> x++-- | Like 'processValue' but on failure prints to stderr and exits the program.+processValueIO :: Mode a -> [String] -> IO a+processValueIO m xs = case process m xs of+    Left x -> do hPutStrLn stderr x; exitFailure+    Right x -> return x   -- | Create a help flag triggered by @-?@/@--help@.
System/Console/CmdArgs/Explicit/Type.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-}  module System.Console.CmdArgs.Explicit.Type where @@ -7,9 +6,8 @@ import Data.Char import Data.List import Data.Maybe-#if __GLASGOW_HASKELL__ < 709 import Data.Monoid-#endif+import Prelude   -- | A name, either the name of a flag (@--/foo/@) or the name of a mode.
cmdargs.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.18 build-type:         Simple name:               cmdargs-version:            0.10.16+version:            0.10.17 license:            BSD3 license-file:       LICENSE category:           Console