packages feed

ReadArgs 1.1 → 1.2

raw patch · 2 files changed

+34/−10 lines, 2 filesdep +system-filepathdep +textdep ~hspecPVP ok

version bump matches the API change (PVP)

Dependencies added: system-filepath, text

Dependency ranges changed: hspec

API changes (from Hackage documentation)

+ ReadArgs: instance [overlap ok] Arguable FilePath
+ ReadArgs: instance [overlap ok] Arguable Text

Files

ReadArgs.cabal view
@@ -1,5 +1,5 @@ Name:                ReadArgs-Version:             1.1+Version:             1.2 Synopsis:            Simple command line argument parsing  Description:         @@ -23,9 +23,10 @@   @   .   Any type that has both @Typeable@ and @Read@ instances-  can be used.  Both @Char@ and @String@ are handled specially so that+  can be used. @Char@, @String@, and @Text@ are handled specially so that   command line arguments for both do not require quotes (as their -  @Read@ instances do).+  @Read@ instances do). A special instance is provided for @FilePath@ so +  that no constructor or quotes are required.   .   @readArgs@ also supports optional arguments and variadic arguments.   Optional arguments are specified using @Maybe@, and variadic arguments @@ -82,7 +83,9 @@   Exposed-modules:     ReadArgs    Build-depends: -    base >= 4.3.1.0 && < 5+    base >= 4.3.1.0 && < 5,+    system-filepath >= 0.4.7 && < 0.5,+    text >= 0.11.1.13 && < 12    Test-Suite ReadArgsSpec   type:@@ -92,12 +95,16 @@     ReadArgsSpec.hs    Build-depends:       -    hspec >= 0.9,-    base >= 4.3.1.0 && < 5+    hspec >= 1.3 && < 2,+    base >= 4.3.1.0 && < 5,+    system-filepath >= 0.4.7 && < 0.5,+    text >= 0.11.1.13 && < 12    Executable ReadArgsEx   Main-Is:     ReadArgsEx.hs    Build-depends: -    base >= 4.3.1.0 && < 5+    base >= 4.3.1.0 && < 5,+    system-filepath >= 0.4.7 && < 0.5,+    text >= 0.11.1.13 && < 12
ReadArgs.hs view
@@ -7,9 +7,14 @@ import Data.List  import Data.Typeable  +import Data.Text (Text, pack)+import Filesystem.Path (FilePath)+import Filesystem.Path.CurrentOS (fromText)+import Prelude hiding (FilePath)+ import System.Environment import System.Exit-import System.IO+import System.IO hiding (FilePath)  -- |parse the desired argument tuple from the command line or  --  print a simple usage statment and quit@@ -40,7 +45,7 @@ instance (Typeable t, Read t) => Arguable t where   parse s = case reads s of     [(i,"")] -> Just i-    otherwise -> Nothing+    _ -> Nothing   name t = showsTypeRep (typeOf t) ""  -- |string is a special case, so that we don't force the user to double-quote@@ -49,11 +54,23 @@   parse = Just   name _ = "String" +-- |Text is a special case, so that we don't force the user to double-quote+-- their input+instance Arguable Text where+  parse = Just . pack+  name _ = "Text"++-- |FilePath is a special case, so that we don't force the user to double-quote+-- their input+instance Arguable FilePath where+  parse = Just . fromText . pack+  name _ = "FilePath"+ -- |char is a special case, so that we don't force the user to single-quote -- their input instance Arguable Char where   parse [x] = Just x-  parse xs = Nothing+  parse _ = Nothing   name _ = "Char"  -- |a class for types that can be parsed from some number of command line