packages feed

simple-cmd 0.2.0.1 → 0.2.1

raw patch · 4 files changed

+57/−5 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ SimpleCmd: cmdTry_ :: String -> [String] -> IO ()
+ SimpleCmd: ifM :: Monad m => m Bool -> m a -> m a -> m a
+ SimpleCmd: needProgram :: String -> IO ()
+ SimpleCmd: whenM :: Monad m => m Bool -> m () -> m ()

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # Revision history for simple-cmd +## 0.2.1 (2019-12-12)+- add cmdTry_: only runs if available+- add ifM and whenM+- add needProgram+ ## 0.2.0 (2019-06-03) - add warning command - API change: sudo and sudo_
README.md view
@@ -1,5 +1,7 @@ [![Build Status](https://travis-ci.org/juhp/simple-cmd.png)](https://travis-ci.org/juhp/simple-cmd) [![Hackage](http://img.shields.io/hackage/v/simple-cmd.png)](http://hackage.haskell.org/package/simple-cmd)+[![Stackage LTS](http://stackage.org/package/simple-cmd/badge/lts)](http://stackage.org/lts/package/simple-cmd)+[![Stackage Nightly](http://stackage.org/package/simple-cmd/badge/nightly)](http://stackage.org/nightly/package/simple-cmd)  # simple-cmd 
SimpleCmd.hs view
@@ -29,7 +29,7 @@ module SimpleCmd (   cmd, cmd_,   cmdBool,-  cmdIgnoreErr,+  cmdIgnoreErr, {- badly named -}   cmdLines,   cmdMaybe,   cmdLog, cmdlog {-TODO: remove for 0.3 -},@@ -38,9 +38,12 @@   cmdSilent,   cmdStdIn,   cmdStdErr,+  cmdTry_,   error',   egrep_, grep, grep_,+  ifM,   logMsg,+  needProgram,   removePrefix, removeStrictPrefix, removeSuffix,   shell, shell_,   shellBool,@@ -49,6 +52,7 @@   PipeCommand,   pipe, pipe_, pipeBool,   pipe3_, pipeFile_,+  whenM,   (+-+)) where  #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,0))@@ -58,7 +62,7 @@ import Control.Monad  import Data.List (stripPrefix)-import Data.Maybe (isNothing, fromMaybe)+import Data.Maybe (isJust, isNothing, fromMaybe)  import System.Directory (findExecutable) import System.Exit (ExitCode (..))@@ -206,6 +210,15 @@   (_exit, out, _err) <- readProcessWithExitCode c args input   return out +-- | 'cmdTry_ c args' runs the command if available+--+-- @since 0.2.1+cmdTry_ :: String -> [String] -> IO ()+cmdTry_ c args = do+  have <- findExecutable c+  when (isJust have) $+    cmd_ c args+ -- | 'grep pat file' greps pattern in file, and returns list of matches -- -- @since 0.1.2@@ -288,6 +301,10 @@ warning :: String -> IO () warning = hPutStrLn stderr ++-- | Type alias for a command in a pipe+--+-- @since 0.2.0 type PipeCommand = (String,[String])  -- | Return stdout from piping the output of one process to another@@ -354,3 +371,26 @@       void $ waitForProcess p1       void $ waitForProcess p2 +-- | Monadic if+-- @ifM test actTrue actFalse@+-- (taken from protolude)+--+-- @since 0.2.1+ifM :: Monad m => m Bool -> m a -> m a -> m a+ifM p x y = p >>= \b -> if b then x else y++-- | Monadic when+-- @whenM test action@+--+-- @since 0.2.1+whenM :: Monad m => m Bool -> m () -> m ()+whenM p x = p >>= \b -> when b x++-- | Assert program in PATH+-- @needProgram progname@+--+-- @since 0.2.1+needProgram :: String -> IO ()+needProgram prog = do+  mx <- findExecutable prog+  unless (isJust mx) $ error' $ "program needs " ++ prog
simple-cmd.cabal view
@@ -1,5 +1,5 @@ name:                simple-cmd-version:             0.2.0.1+version:             0.2.1 synopsis:            Simple String-based process commands description:             Simple wrappers over System.Process@@ -17,7 +17,8 @@ cabal-version:       >=1.10 extra-source-files:  README.md ChangeLog.md TODO tested-with:         GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3,-                     GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5+                     GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5,+                     GHC == 8.8.1  source-repository head   type:     git@@ -27,7 +28,11 @@   exposed-modules:     SimpleCmd,                        SimpleCmd.Git,                        SimpleCmd.Rpm-  build-depends:       base < 5, directory, filepath, process >= 1.4.3.0, unix+  build-depends:       base < 5,+                       directory,+                       filepath,+                       process >= 1.4.3.0,+                       unix   default-language:    Haskell2010   default-extensions:  CPP   ghc-options:   -fwarn-missing-signatures -Wall