packages feed

cli 0.1.0 → 0.1.1

raw patch · 5 files changed

+23/−13 lines, 5 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

Console/Options.hs view
@@ -65,7 +65,7 @@ setDescription desc  (Command hier _ opts act)    = Command hier desc opts act  setAction :: Action r -> Command r -> Command r-setAction act (Command hier desc opts _)   = Command hier desc opts (Just act)+setAction act (Command hier desc opts _)   = Command hier desc opts (ActionWrapped act)  addOption :: FlagDesc -> Command r -> Command r addOption opt   (Command hier desc opts act) = Command hier desc (opt : opts) act@@ -184,8 +184,8 @@                                 Right (pinnedArgs, remainingArgs) -> do                                     let flags = concat (opts:parsedOpts)                                     case act of-                                        Nothing -> OptionInvalid "no action defined"-                                        Just a  ->+                                        NoActionWrapped -> OptionInvalid "no action defined"+                                        ActionWrapped a  ->                                             let params = Params flags                                                                 pinnedArgs                                                                 remainingArgs
Console/Options/Monad.hs view
@@ -9,6 +9,7 @@     , getNextIndex     ) where +import           Control.Applicative import           Console.Options.Nid import           Console.Options.Types import           Console.Options.Utils@@ -50,7 +51,7 @@                                  }   where     iniCommand :: Command r-    iniCommand = Command (CommandLeaf []) "..." [] Nothing+    iniCommand = Command (CommandLeaf []) "..." [] NoActionWrapped  -- | Return the next unique argument ID getNextID :: OptionDesc r Nid
Console/Options/Types.hs view
@@ -7,6 +7,7 @@     , Command(..)     , CommandHier(..)     , Action+    , ActionWrapper(..)     , UnnamedIndex     -- * User Binders to retrieve their options     , Flag(..)@@ -61,7 +62,7 @@     { getCommandHier        :: CommandHier r     , getCommandDescription :: String     , getCommandOptions     :: [FlagDesc]-    , getCommandAction      :: Maybe (Action r)+    , getCommandAction      :: ActionWrapper r     }  -- | Recursive command tree@@ -77,7 +78,11 @@     }  -- | Represent a program to run-type Action r = (forall a p . Param p => p a -> Ret p a) -> r -- flags+type Action r = (forall a p . Param p => p a -> Ret p a) -> r++data ActionWrapper r = +      ActionWrapped (Action r)+    | NoActionWrapped  class Param p where     type Ret p a :: *
cli.cabal view
@@ -1,5 +1,5 @@ Name:                cli-Version:             0.1.0+Version:             0.1.1 Synopsis:            Command Line Interface Description:      All you need for interacting with users at the Console level@@ -55,6 +55,7 @@   default-language:  Haskell2010   Build-Depends:     base >= 3 && < 5                    , directory+                   , transformers                    , tasty                    , tasty-quickcheck                    , QuickCheck
tests/Cli.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE FlexibleContexts #-} module Main (main) where  import           Control.Applicative@@ -7,7 +8,6 @@ import           Test.Tasty.QuickCheck import           Test.QuickCheck.Monadic -import           Storage.HashFS.Meta import           System.Directory import           Data.List import           Data.Monoid@@ -24,7 +24,8 @@ --commandBar :: Monad m => OptionDesc (m Bool) () commandBar :: OptionDesc (Identity Bool) () commandBar = command "bar" $ do-    a <- flagA+    a  <- flagA+    a2 <- argument "arg1" Right     action $ \toParam -> do         return True @@ -34,11 +35,13 @@         _          -> return False  testParseSuccess name values f =-    testProperty name $ runIdentity $ do+    testProperty name $         let (_,r) = f          in case r of-                OptionSuccess p act -> return (sort values == sort (paramsFlags p)) --act (getParams p)-                _                   -> return False+                OptionSuccess p act -> runIdentity $ return (sort values == sort (paramsFlags p))+                OptionHelp          -> error $ "got help expected success"+                OptionError s       -> error $ "got error " ++ show s ++ " expected success"+                OptionInvalid s     -> error $ "got invalid " ++ show s ++ " expected success"  main = defaultMain $ testGroup "options"     [ testGroup "help"@@ -46,7 +49,7 @@         , testParseHelp "2" $ parseOptions (commandBar) ["options", "argument", "-h", "a"]         ]     , testGroup "success"-        [ testParseSuccess "1" [] $ parseOptions (commandBar) ["bar", "-a", "option-a"]+        [ testParseSuccess "1" [] $ parseOptions (commandBar >> commandFoo) ["bar", "arg1"]         , testParseSuccess "2" [] $ parseOptions (commandBar >> commandFoo) ["foo", "a"]         ]     ]