packages feed

simple-cmd-args 0.1.0.1 → 0.1.1

raw patch · 4 files changed

+67/−13 lines, 4 filesdep ~optparse-applicativePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: optparse-applicative

API changes (from Hackage documentation)

+ SimpleCmdArgs: argumentWith :: ReadM a -> String -> Parser a
+ SimpleCmdArgs: optionWith :: ReadM a -> Char -> String -> String -> String -> Parser a
+ SimpleCmdArgs: optionalWith :: ReadM a -> Char -> String -> String -> String -> a -> Parser a
+ SimpleCmdArgs: simpleCmdArgsWithMods :: Maybe Version -> InfoMod (IO ()) -> Parser (IO ()) -> IO ()
+ SimpleCmdArgs: strOptionWith :: Char -> String -> String -> String -> Parser String
+ SimpleCmdArgs: strOptionalWith :: Char -> String -> String -> String -> String -> Parser String
+ SimpleCmdArgs: switchWith :: Char -> String -> String -> Parser Bool

Files

CHANGELOG.md view
@@ -2,6 +2,11 @@  `simple-cmd-args` uses [PVP Versioning][1]. +## 0.1.1+- add switchWith, strOptionWith, optionWith, optionalWith,+  strOptionalWith, argumentWith+- export simpleCmdArgsWithMods+ ## 0.1.0.1 - fix and improve haddock documentation 
README.md view
@@ -7,7 +7,7 @@ [![Build status](https://secure.travis-ci.org/juhp/simple-cmd-args.svg)](https://travis-ci.org/juhp/simple-cmd-args)  A thin layer over optparse-applicative that avoids type plumbing for-commands by using `Parser (IO ())`. It also supports with subcommands.+subcommands by using `Parser (IO ())`.  ## Usage @@ -19,8 +19,8 @@ main =   simpleCmdArgs Nothing "my example tool" "Longer description..." $   subcommands-    [ Subcommand "echo" (putStrLn <$> strArg "NAME") "Print name"-    , Subcommand "ls" (cmd_ "ls" <$> some (strArg "FILE...")) "Touch FILE"+    [ Subcommand "echo" "Print name" $ putStrLn <$> strArg "NAME"+    , Subcommand "ls" "Touch FILE" $ cmd_ "ls" <$> some (strArg "FILE...")     ] ``` 
SimpleCmdArgs.hs view
@@ -9,12 +9,19 @@ module SimpleCmdArgs   (simpleCmdArgs,    simpleCmdArgs',+   simpleCmdArgsWithMods,    Subcommand(..),    subcommands,    strArg,+   switchWith,    switchMods,+   strOptionWith,+   optionWith,    optionMods,+   strOptionalWith,+   optionalWith,    optionalMods,+   argumentWith   ) where @@ -41,7 +48,7 @@   -- ^ commands   -> IO () simpleCmdArgs mversion h pd =-  simpleCmdArgsWithMods mods mversion+  simpleCmdArgsWithMods mversion mods   where     mods = fullDesc <> header h <> progDesc pd @@ -59,17 +66,17 @@   -- ^ commands   -> IO () simpleCmdArgs' mversion h pd =-  simpleCmdArgsWithMods mods mversion+  simpleCmdArgsWithMods mversion mods   where     mods = fullDesc <> header h <> progDesc pd <> noIntersperse  -- | Generic parser executor with explicit info modifiers simpleCmdArgsWithMods ::-  InfoMod (IO ()) -- ^ modifiers-  -> Maybe Version -- ^ version string+  Maybe Version -- ^ version string+  -> InfoMod (IO ()) -- ^ modifiers   -> Parser (IO ()) -- ^ commands   -> IO ()-simpleCmdArgsWithMods mods mversion cmdsParser = join $+simpleCmdArgsWithMods mversion mods cmdsParser = join $   customExecParser (prefs showHelpOnEmpty)   (case mversion of     (Just version) -> info (helper <*> versionOption version <*> cmdsParser) mods@@ -93,6 +100,13 @@ strArg :: String -> Parser String strArg var = strArgument (metavar var) +-- | switch with Mods+--+-- > switchWith 'o' "option" "help description"+switchWith :: Char -> String -> String -> Parser Bool+switchWith s l h =+  switch (switchMods s l h)+ -- | @Mod@s for a switch. -- -- > switchMods 'o' "option" "help description"@@ -101,6 +115,20 @@ switchMods s l h =   short s <> long l <> help h +-- | strOption with Mods+--+-- > strOptionWith 'o' "option" "METAVAR" "help description"+strOptionWith :: Char -> String -> String -> String -> Parser String+strOptionWith s l meta h =+  strOption (optionMods s l meta h)++-- | option with Mods+--+-- > optionWith 'o' "option" "METAVAR" "help description"+optionWith :: ReadM a -> Char -> String -> String -> String -> Parser a+optionWith r s l meta h =+  option r (optionMods s l meta h)+ -- | @Mod@s for a mandatory option. -- -- > optionMods 'o' "option" "METAVAR" "help description"@@ -109,6 +137,20 @@ optionMods s l meta h =   short s <> long l <> metavar meta <> help h +-- | strOptional with Mods+--+-- > strOptionalWith 'o' "option" "METAVAR" "help description" default+strOptionalWith :: Char -> String -> String -> String -> String -> Parser String+strOptionalWith s l meta h d =+  strOption (optionalMods s l meta h d)++-- | optional option with Mods, includes a default value.+--+-- > optionalWith 'o' "option" "METAVAR" "help description" default+optionalWith :: ReadM a -> Char -> String -> String -> String -> a -> Parser a+optionalWith r s l meta h d =+  option r (optionalMods s l meta h d)+ -- | @Mod@s for an optional option: includes a default value. -- -- > optionalMods 'o' "option" "METAVAR" "help description" default@@ -116,3 +158,10 @@   Char -> String -> String -> String -> a -> Mod f a optionalMods s l meta h d =   short s <> long l <> metavar meta <> help h <> value d++-- | argument with METAVAR+--+-- > argumentWith auto "METAVAR"+argumentWith :: ReadM a -> String -> Parser a+argumentWith r meta =+  argument r (metavar meta)
simple-cmd-args.cabal view
@@ -1,12 +1,12 @@ cabal-version:       1.18 name:                simple-cmd-args-version:             0.1.0.1+version:             0.1.1 synopsis:            Simple command args parsing and execution description:             This is a small wrapper over optparse-applicative which-            allows combining args parsers directly with IO commands,-            avoiding command type boilerplate. It supports subcommands-            and also provides a few option Mod functions.+            allows combining args parsers directly with IO commands.+            For subcommands this can avoid type boilerplate.+            It also provides a few functions for common Mod combinations. homepage:            https://github.com/juhp/simple-cmd-args bug-reports:         https://github.com/juhp/simple-cmd-args/issues license:             BSD3@@ -19,7 +19,7 @@ extra-doc-files:     README.md                    , CHANGELOG.md tested-with:         GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2,-                     GHC == 8.4.4, GHC == 8.6.3+                     GHC == 8.4.4, GHC == 8.6.4  source-repository head   type:                git