packages feed

cli 0.0.3 → 0.0.4

raw patch · 2 files changed

+17/−4 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Application.CLI: execute :: IO a -> Options -> IO a

Files

Application/CLI.hs view
@@ -18,8 +18,9 @@ --   instance CLI MyCommand where --      name _ = "cmd" --      desc _ = "just echo the given arguments"---      options _ = [ ]---      action _ _ opts = mapM_ putStrLn opts+--      options _ = [ OptHelp [] (Just "string") "the message to print" ]+--      action _ _ =+--          withStr "string" $ \str -> exectute $ putStrLn str -- @ -- -- And to create you application, you need 2 functions (initialize, with and defaultMain).@@ -59,6 +60,7 @@     , withParameterStr     , withOptionalParameterStr     , withFlag+    , execute     ) where  import Application.CLI.Class@@ -96,7 +98,8 @@     options _  = [ OptHelp [] (Just "command") "print the help message for a specific command"                  ]     action  _ ctx =-        withOptionalStr $ \mcommand _ -> do+        withOptionalStr $ \mcommand ->+        execute $ do             case mcommand of                 Nothing -> printStdHelp                 Just c  -> printCmdHelp c@@ -204,6 +207,16 @@     case break (flip elem flags) l of         (xs1, [])    -> f False xs1         (xs1, _:xs2) -> f True  (xs1 ++ xs2)++-- | This function makes the use of the other function easier+-- and also provide a verification that there is no "unused function".+-- If there is unexpected options remaining, the program will stop and an+-- error message will be printed+execute :: IO a+        -> Options+        -> IO a+execute f [] = f+execute _ l  = error $ "this options are not expected: " ++ intercalate " " l  ------------------------------------------------------------------------------- --                             Default Main                                  --
cli.cabal view
@@ -1,5 +1,5 @@ Name:                cli-Version:             0.0.3+Version:             0.0.4 Synopsis:            Simple Command Line Interface Library Description:     This package provides a simple Command Line Library