packages feed

process-streaming 0.9.2 → 0.9.2.1

raw patch · 3 files changed

+22/−8 lines, 3 files

Files

process-streaming.cabal view
@@ -1,5 +1,5 @@ name:          process-streaming-version:       0.9.2+version:       0.9.2.1 license:       BSD3 license-file:  LICENSE data-files:    
src/System/Process/Streaming.hs view
@@ -367,8 +367,7 @@ foldErr :: Fold1 ByteString e r -> Streams e r foldErr =  liftFold2 . Pipes.Transduce.liftSecond -{-| Consume standard output and error together.	See also the 'combine' function-    re-exported from "Pipes.Transduce".+{-| Consume standard output and error together. This enables combining them in a single stream. See also 'System.Process.Streaming.Text.bothAsUtf8x' and 'System.Process.Streaming.Text.combinedLines'.  -} foldOutErr :: Fold2 ByteString ByteString e r -> Streams e r@@ -422,7 +421,7 @@  >>> :{      execute (piped (shell "{ cat ; sleep 1 ; echo eee 1>&2 ; }")) $ -        (\_ _ o e oe ec -> (o,e,oe,ec)) +        (\_ _ ob eb et oet c -> (ob,eb,et,oet,c))          <$>         feedBytes (Just "aaa")          <*> @@ -432,11 +431,13 @@         <*>         foldErr intoLazyBytes          <*>-        foldOutErr (combined (PT.lines PT.utf8x) (PT.lines PT.utf8x) PT.intoLazyText)+        foldErr (PT.asUtf8x PT.intoLazyText)         <*>+        foldOutErr (PT.bothAsUtf8x (PT.combinedLines PT.intoLazyText))+        <*>         exitCode     :}-("aaabbb","eee\n","aaabbb\neee\n",ExitSuccess)+("aaabbb","eee\n","eee\n","aaabbb\neee\n",ExitSuccess)  -} newtype Streams e r = 
src/System/Process/Streaming/Text.hs view
@@ -11,6 +11,7 @@ module System.Process.Streaming.Text (          -- * Examples         -- $examples+        -- $examplescombined         module Pipes.Transduce.Text     ) where @@ -23,6 +24,7 @@ >>> import qualified Pipes >>> import Pipes.Transduce >>> import Control.Applicative+>>> import Control.Monad >>> import System.Process.Streaming >>> import qualified System.Process.Streaming.Text as PT >>> import qualified Control.Foldl as L@@ -52,6 +54,10 @@     :} ["foo","bar"] +-}++{- $examplescombined+     Sometimes we want to consume the lines in @stdout@ and @stderr@ as a single     text stream. We can do this with 'System.Process.Streaming.foldOutErr' and     'Pipes.Transduce.Text.combinedLines'.@@ -73,7 +79,14 @@     :} "+ooo\n-eee\n" --}+    Fail when an error message appears in the combined @stdout@ and @stderr@ stream. This uses the 'System.Process.Streaming.Text.eachLine' function. We switched to 'System.Process.Streaming.executeFallibly' to enable either-like failures. - +>>> :{ +      executeFallibly (piped (shell "{ echo ooo ; sleep 1 ; echo _error_ 1>&2 ; }")) $ +          let check line = runExceptT $ when (Data.Text.Lazy.isInfixOf "error" line) $ throwE line+          in  foldOutErr (PT.bothAsUtf8x (PT.combinedLines (PT.eachLine check)))+    :}+Left "_error_"++-}