shellout-0.1.0.0: A threaded manager for Haskell that can run and stream external process output/err/exits

Safe HaskellNone
LanguageHaskell2010

Shellout

Description

Shell is a threaded manager that can run external processes and call functions of the Driver on process outputerrexit.

Synopsis

Documentation

data Driver a Source #

Driver is a collection of functions that describe what to do on process output

Constructors

Driver 

Fields

  • initialState :: Text -> a

    (optionally) do something with the task name, and initialize data that will be passed between your handlers. you could store things like the task name, a spinner's position and last spin time, etc.

  • handleNothing :: a -> IO a

    what to do when polling returns Nothing, so it's waiting on more output from the task, but the task still hasn't exited. usually it's sleep.

  • handleOut :: a -> Text -> IO a

    what to do on stdout from the shell command. You could colorize it, append it to list of output (you could keep a list in the a), etc.

  • handleErr :: a -> Text -> IO a

    what to do on stderr. Same things go as stdout.

  • handleSuccess :: a -> IO ()

    what to do when a task completes successfully

  • handleFailure :: a -> IO ()

    what to do when a task doesn't complete successfully

type Shell = TaskName -> Cmd -> IO () Source #

Shell takes a task name and an external command and executes the given callbacks in the provided driver

type TaskName = Text Source #

Task is the description of an external process

type Cmd = Text Source #

Cmd is the external command like 'cat file.txt' to run

new :: Driver a -> IO Shell Source #

creates a new processor to run external processes in, spawns a thread to run the processor loop, then returns a Shell that can send commands to the processor loop, and react to them with functions from the Driver