parseargs 0.1.5.2 → 0.2
raw patch · 4 files changed
+18/−13 lines, 4 files
Files
- README.md +5/−0
- System/Console/ParseArgs.hs +3/−3
- parseargs-example.hs +8/−8
- parseargs.cabal +2/−2
README.md view
@@ -38,6 +38,11 @@ The 0.1.5.2 release fixes some missing documentation. +The 0.2 release cleans up some namespace pollution by+removing `ArgRecord` and the `args` accessor from the public+namespace. This allows the use of the name `args` by the+user to describe program arguments.+ This library is not what I set out to build. It definitely could also use some work. However, I use it all the time for writing little programs. I thought others might find it
System/Console/ParseArgs.hs view
@@ -46,7 +46,7 @@ -- |The argument parser returns an opaque map -- from argument index to parsed argument data -- (plus some convenience information).- ArgRecord, Args(..),+ Args(argsUsage,argsProgName, argsRest), parseArgs, parseArgsIO, -- ** Using parse results -- |Query functions permit checking for the existence@@ -172,8 +172,8 @@ -- |The type of the mapping from argument index to value. newtype ArgRecord a = ArgRecord (Map.Map a Argval) --- |The data structure `parseArgs` produces. The key--- element is the `ArgRecord` `args`.+-- |The data structure `parseArgs` produces. There is a hidden+-- field that describes the actual parse. data (Ord a) => Args a = Args { args :: ArgRecord a -- ^The argument map. , argsProgName :: String -- ^Basename of 0th argument.
parseargs-example.hs view
@@ -49,23 +49,23 @@ main :: IO () main = do- argv <- parseArgsIO + args <- parseArgsIO (ArgsParseControl (ArgsTrailing "junk") ArgsSoftDash) argd putStrLn "parse successful"- when (gotArg argv OptionFlag)+ when (gotArg args OptionFlag) (putStrLn "saw flag")- case (getArg argv OptionFlagString) of+ case (getArg args OptionFlagString) of Just s -> putStrLn ("saw string " ++ s) Nothing -> return ()- case (getArg argv OptionFlagInt) of+ case (getArg args OptionFlagInt) of Just d -> putStrLn ("saw int " ++ (show (d::Int))) Nothing -> return ()- case (getArg argv OptionPreoptional) of+ case (getArg args OptionPreoptional) of Just s -> putStrLn ("saw pre-optional " ++ s) Nothing -> return ()- putStrLn ("saw fixed " ++ (fromJust (getArgString argv OptionFixed)))- case (getArg argv OptionOptional) of+ putStrLn ("saw fixed " ++ (fromJust (getArgString args OptionFixed)))+ case (getArg args OptionOptional) of Just s -> putStrLn ("saw optional " ++ s) Nothing -> return ()- putStrLn ("saw rest: " ++ show (argsRest argv))+ putStrLn ("saw rest: " ++ show (argsRest args))
parseargs.cabal view
@@ -2,7 +2,7 @@ Build-Type: Simple Description: Parse command-line arguments -- Don't forget to bump the source-repository this below-Version: 0.1.5.2+Version: 0.2 Cabal-Version: >= 1.6 License: BSD3 License-File: COPYING@@ -30,4 +30,4 @@ Source-repository this Type: git Location: git://github.com/BartMassey/parseargs.git- Tag: v0.1.5.2+ Tag: v0.2