-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Create proper Pipes from System.Process -- -- This package provides functions to build proper Pipes from Unix shell -- commands like tr, ls or echo in a concise way. -- -- Build with cabal configure --enable-tests to build the little -- hspec test. @package pipes-shell @version 0.1.2 -- | This module contains a few functions to use unix-y shell commands as -- Pipes. -- -- The output ByteStrings from pipeCmdEnv and friends are -- not line-wise, but chunk-wise. To get proper lines use the -- pipes-bytestring and the upcoming pipes-text machinery. Note that exit -- code handling is not yet implemented. -- -- All code examples in this module assume following qualified imports: -- Pipes.Prelude as P, Pipes.ByteString as PBS, Data.ByteString.Char8 as -- BSC module Pipes.Shell -- | This is the workhorse of this package. -- -- It provides the direct interface from a shell command string to a -- proper Pipe. -- --
-- >>> runShell $ yield (BSC.pack "aaa") >?> pipeCmdEnv Nothing "tr 'a' 'A'" >-> PBS.stdout -- AAA --pipeCmdEnv :: MonadSafe m => Maybe [(String, String)] -> String -> Pipe (Maybe ByteString) (Either ByteString ByteString) m () -- | Like pipeCmdEnv but doesn't set enviorment varaibles pipeCmd :: MonadSafe m => String -> Pipe (Maybe ByteString) (Either ByteString ByteString) m () -- | Like pipeCmd but ignores stderr pipeCmd' :: MonadSafe m => String -> Pipe (Maybe ByteString) ByteString m () -- | Like pipeCmdEnv but closes the input end immediately. -- -- Useful for command line tools like ls producerCmdEnv :: MonadSafe m => Maybe [(String, String)] -> String -> Producer (Either ByteString ByteString) m () -- | Like producerCmdEnv but doesn't set enviorment varaibles producerCmd :: MonadSafe m => String -> Producer (Either ByteString ByteString) m () -- | Like producerCmd but ignores stderr producerCmd' :: MonadSafe m => String -> Producer ByteString m () -- | Like pipeCmd but closes the output end immediately. -- -- Useful for command line tools like cat > test.file consumerCmdEnv :: MonadSafe m => Maybe [(String, String)] -> String -> Consumer (Maybe ByteString) m () -- | Like consumerCmdEnv but doesn't set enviorment varaibles consumerCmd :: MonadSafe m => String -> Consumer (Maybe ByteString) m () -- | An ad-hoc typeclass to get the varadic arguments and DWIM behavoir of -- cmdEnv class Cmd cmd where cmd = cmdEnv Nothing cmdEnv :: Cmd cmd => Maybe [(String, String)] -> String -> cmd cmd :: (Cmd cmd, Cmd cmd) => String -> cmd -- | An ad-hoc typeclass to get the varadic arguments and DWIM behavoir of -- cmd'. This class is seperate from Cmd to make the return -- types work out. class Cmd' cmd cmd' :: Cmd' cmd => String -> cmd -- | Like >-> but marks the end of the left pipe with -- markEnd. It's needed because pipeCmdEnv has to know when -- the upstream Pipe finishes. -- -- The basic rule is: -- --
-- Replace every >-> with >?> when it's in front of -- pipeCmdEnv or similar. --(>?>) :: Monad m => Proxy a' a () b m r -> Proxy () (Maybe b) c' c m r -> Proxy a' a c' c m r -- | Mark the end of a pipe. It wraps all values in a Just and -- yields *one* Nothing after the upstream pipe finished. markEnd :: Monad m => Proxy a' a b' b m r -> Proxy a' a b' (Maybe b) m r -- | Ignore stderr from a pipeCmd ignoreErr :: Monad m => Pipe (Either ByteString ByteString) ByteString m () -- | Ignore stdout from a pipeCmd ignoreOut :: Monad m => Pipe (Either ByteString ByteString) ByteString m () -- | A simple run function for Pipes that live in SafeT -- IO runShell :: Effect (SafeT IO) r -> IO r instance MonadSafe m => Cmd' (Consumer (Maybe ByteString) m ()) instance MonadSafe m => Cmd' (Producer ByteString m ()) instance MonadSafe m => Cmd' (Pipe (Maybe ByteString) ByteString m ()) instance Cmd' cmd => Cmd' (String -> cmd) instance MonadSafe m => Cmd (Consumer (Maybe ByteString) m ()) instance MonadSafe m => Cmd (Producer (Either ByteString ByteString) m ()) instance MonadSafe m => Cmd (Pipe (Maybe ByteString) (Either ByteString ByteString) m ()) instance Cmd cmd => Cmd (String -> cmd)