parseargs 0.2.0.1 → 0.2.0.2
raw patch · 4 files changed
+18/−14 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +2/−0
- System/Console/ParseArgs.hs +12/−10
- parseargs-example.hs +2/−2
- parseargs.cabal +2/−2
README.md view
@@ -45,6 +45,8 @@ The 0.2.0.1 release cleans up a bunch of documentation nits and cleans up copyright notices and license information. +The 0.2.0.2 release fixes the botched release of 0.2.0.1. Sigh.+ 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
@@ -19,7 +19,7 @@ -- supplied as a list of `Arg` records, built up -- using the functions described here. Arg(..),- Argtype(..),+ Argtype(..), ArgsComplete(..), ArgsDash(..), APCData(..),@@ -76,8 +76,10 @@ -- for positional data arguments. -- -- There are two cases:+-- -- (1) The argument is a flag, in which case at least -- one of `argAbbr` and `argName` is provided;+-- -- (2) The argument is positional, in which case neither -- `argAbbr` nor `argName` are provided, but `argData` is. -- @@ -93,7 +95,7 @@ , argName :: Maybe String -- ^\"Long name\" of flag. , argData :: Maybe DataArg -- ^Datum description. , argDesc :: String -- ^Documentation for the argument.- }+ } -- |The types of an argument carrying data. The constructor@@ -281,7 +283,7 @@ keymap_from_list l = foldl add_entry Map.empty l where- add_entry m (k, a) =+ add_entry m (k, a) = case Map.member k m of False -> Map.insert k a m True -> argdesc_error ("duplicate argument description name " ++@@ -429,7 +431,7 @@ posn_args = filter arg_posn argd n = maximum (map (length . arg_string) argd) --- top (summary) line- summary_line =+ summary_line = "usage: " ++ prog_name ++ perhaps (not (null flag_args))@@ -445,7 +447,7 @@ arg_lines = concatMap (arg_line n) argd where arg_line na a = let s = arg_string a in- " " ++ s +++ " " ++ s ++ replicate (na - (length s)) ' ' ++ " " ++ argDesc a ++ "\n" --- simple recursive-descent parser@@ -457,22 +459,22 @@ parse usage name_hash abbr_hash (am, posn, rest) av@(aa : aas) = case aa of "--" -> case getAPCData apcData of- ArgsParseControl ArgsComplete ArgsHardDash ->+ ArgsParseControl ArgsComplete ArgsHardDash -> parseError usage ("unexpected -- " ++ "(extra arguments not allowed)") _ -> ([], (am, posn, (rest ++ aas)))- s@('-' : '-' : name)+ s@('-' : '-' : name) | isJust (Map.lookup name name_hash) || apcDash (getAPCData apcData) == ArgsHardDash -> case Map.lookup name name_hash of- Just ad ->+ Just ad -> let (args', am') = peel s ad aas in (args', (am', posn, rest)) Nothing -> case getAPCData apcData of ArgsParseControl ArgsInterspersed _ -> (aas, (am, posn, rest ++ ["--" ++ name]))- _ ->+ _ -> parseError usage ("unknown argument --" ++ name) ('-' : abbr : abbrs)@@ -500,7 +502,7 @@ let (_, req_posn) = partition arg_optional posn in case length av - length req_posn of n_extra | n_extra > 0 || (n_extra == 0 && arg_required p) ->- let (args', am') = peel (dataArgName $ fromJust $+ let (args', am') = peel (dataArgName $ fromJust $ argData p) p av in (args', (am', ps, rest)) 0 -> (av, (am, ps, rest))
parseargs-example.hs view
@@ -53,8 +53,8 @@ main :: IO () main = do- args <- parseArgsIO- (ArgsParseControl (ArgsTrailing "junk") ArgsSoftDash)+ args <- parseArgsIO + (ArgsParseControl (ArgsTrailing "junk") ArgsSoftDash) argd putStrLn "parse successful" when (gotArg args OptionFlag)
parseargs.cabal view
@@ -6,7 +6,7 @@ Build-Type: Simple Description: Parse command-line arguments -- Don't forget to bump the source-repository this below-Version: 0.2.0.1+Version: 0.2.0.2 Cabal-Version: >= 1.6 License: BSD3 License-File: COPYING@@ -34,4 +34,4 @@ Source-repository this Type: git Location: git://github.com/BartMassey/parseargs.git- Tag: v0.2.0.1+ Tag: v0.2.0.2