packages feed

simple-cmd-args 0.1.0 → 0.1.0.1

raw patch · 4 files changed

+45/−23 lines, 4 files

Files

CHANGELOG.md view
@@ -2,8 +2,10 @@  `simple-cmd-args` uses [PVP Versioning][1]. -0.1.0-=====-* Initial release with subcommands and option Mod functions+## 0.1.0.1+- fix and improve haddock documentation++## 0.1.0+- Initial release with subcommands and option Mod functions  [1]: https://pvp.haskell.org
README.md view
@@ -7,8 +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-the common use case of a commandline tool with subcommands,-by using `Parser (IO ())`+commands by using `Parser (IO ())`. It also supports with subcommands.  ## Usage @@ -25,5 +24,4 @@     ] ``` -See more [https://github.com/juhp/simple-cmd-args/tree/master/examples](examples/).-+See more [examples](https://github.com/juhp/simple-cmd-args/tree/master/examples).
SimpleCmdArgs.hs view
@@ -1,12 +1,20 @@+{-|+This library provides a thin layer on optparse-applicative+argument and option parsing, using @Parser (IO ())@,+applying commands directly to their argument parsing.++A few option Mod functions are also provided.+-}+ module SimpleCmdArgs-  (optionMods,-   optionalMods,-   simpleCmdArgs,+  (simpleCmdArgs,    simpleCmdArgs',-   strArg,    Subcommand(..),    subcommands,-   switchMods+   strArg,+   switchMods,+   optionMods,+   optionalMods,   ) where @@ -20,6 +28,8 @@ import Options.Applicative  -- | Parser executor (allows interspersed args and options)+--+-- > simpleCmdArgs (Just version) "summary" "program description" $ myCommand <$> myOptParser <*> myargsParser simpleCmdArgs ::   Maybe Version   -- ^ version string@@ -36,6 +46,8 @@     mods = fullDesc <> header h <> progDesc pd  -- | Parser executor without interspersing options and args+--+-- > simpleCmdArgs' Nothing "summary" "program description" $ myCommand <$> myOptParser <*> myargsParser simpleCmdArgs'   :: Maybe Version   -- ^ version string@@ -53,12 +65,9 @@  -- | Generic parser executor with explicit info modifiers simpleCmdArgsWithMods ::-  InfoMod (IO ()) ->-  -- ^ modifiers-  Maybe Version-  -- ^ version string-  -> Parser (IO ())-  -- ^ commands+  InfoMod (IO ()) -- ^ modifiers+  -> Maybe Version -- ^ version string+  -> Parser (IO ()) -- ^ commands   -> IO () simpleCmdArgsWithMods mods mversion cmdsParser = join $   customExecParser (prefs showHelpOnEmpty)@@ -69,27 +78,40 @@     versionOption ver =       infoOption (showVersion ver) (long "version" <> help "Show version") -data Subcommand = Subcommand String String (Parser (IO ()))+-- | > Subcommand "command" "help description text" $ myCommand <$> optParser+data Subcommand =+  Subcommand String String (Parser (IO ())) +-- | list of @Subcommand@ that can be run by @simpleCmdArgs@ subcommands :: [Subcommand] -> Parser (IO ()) subcommands = subparser . mconcat . map cmdToParse   where     cmdToParse (Subcommand name cmddesc cmdparse) =       command name (info cmdparse (progDesc cmddesc)) +-- | A string arg parser with a METAVAR for help strArg :: String -> Parser String strArg var = strArgument (metavar var) +-- | @Mod@s for a switch.+--+-- > switchMods 'o' "option" "help description" switchMods :: HasName f =>   Char -> String -> String -> Mod f a switchMods s l h =   short s <> long l <> help h +-- | @Mod@s for a mandatory option.+--+-- > optionMods 'o' "option" "METAVAR" "help description" optionMods :: (HasMetavar f, HasName f) =>   Char -> String -> String -> String -> Mod f a optionMods s l meta h =   short s <> long l <> metavar meta <> help h +-- | @Mod@s for an optional option: includes a default value.+--+-- > optionalMods 'o' "option" "METAVAR" "help description" default optionalMods :: (HasMetavar f, HasName f, HasValue f) =>   Char -> String -> String -> String -> a -> Mod f a optionalMods s l meta h d =
simple-cmd-args.cabal view
@@ -1,12 +1,12 @@ cabal-version:       1.18 name:                simple-cmd-args-version:             0.1.0+version:             0.1.0.1 synopsis:            Simple command args parsing and execution description:-            This a small wrapper over optparse-applicative which+            This is a small wrapper over optparse-applicative which             allows combining args parsers directly with IO commands,-            avoiding command types boilerplate. It also provides-            a few option Mod functions.+            avoiding command type boilerplate. It supports subcommands+            and also provides a few option Mod functions. homepage:            https://github.com/juhp/simple-cmd-args bug-reports:         https://github.com/juhp/simple-cmd-args/issues license:             BSD3