leksah-server-0.12.1.2: Metadata collection for leksah

Safe Haskell | None

IDE.Utils.Tool

Description

Support for running external tools. Written mainly for GHCi but with | support for others in mind.

Synopsis

- data ToolOutput
  - = ToolInput String
  - | ToolError String
  - | ToolOutput String
  - | ToolPrompt String
  - | ToolExit ExitCode
- toolline :: ToolOutput -> String
- data ToolCommand = ToolCommand String String (Iteratee ToolOutput IO ())
- data ToolState = ToolState {
  - toolProcessMVar :: MVar ProcessHandle
  - outputClosed :: MVar Bool
  - toolCommands :: Chan ToolCommand
  - toolCommandsRead :: Chan ToolCommand
  - currentToolCommand :: MVar ToolCommand
  }
- toolProcess :: ToolState -> IO ProcessHandle
- newToolState :: IO ToolState
- runTool :: MonadIO m => FilePath -> [String] -> Maybe FilePath -> IO (Enumerator ToolOutput m b, ProcessHandle)
- runTool' :: FilePath -> [String] -> Maybe FilePath -> IO ([ToolOutput], ProcessHandle)
- runInteractiveTool :: ToolState -> CommandLineReader -> FilePath -> [String] -> IO ()
- newGhci :: [String] -> [String] -> Iteratee ToolOutput IO () -> IO ToolState
- newGhci' :: [String] -> Iteratee ToolOutput IO () -> IO ToolState
- executeCommand :: ToolState -> String -> String -> Iteratee ToolOutput IO () -> IO ()
- executeGhciCommand :: ToolState -> String -> Iteratee ToolOutput IO () -> IO ()
- quoteArg :: String -> String
- escapeQuotes :: String -> String
- runCommand :: String -> IO ProcessHandle
- waitForProcess :: ProcessHandle -> IO ExitCode
- interruptProcessGroupOf :: ProcessHandle -> IO ()
- data ProcessHandle
- getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode)
- runInteractiveProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> IO (Handle, Handle, Handle, ProcessHandle)
- runProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> Maybe Handle -> Maybe Handle -> Maybe Handle -> IO ProcessHandle

# Documentation

data ToolOutput Source

Constructors

ToolInput String |
ToolError String |
ToolOutput String |
ToolPrompt String |
ToolExit ExitCode |

Instances

Eq ToolOutput |
Show ToolOutput |
NFData ToolOutput |

toolline :: ToolOutput -> String Source

data ToolCommand Source

Constructors

ToolCommand String String (Iteratee ToolOutput IO ()) |

data ToolState Source

Constructors

ToolState |

Fields

toolProcessMVar :: MVar ProcessHandle
outputClosed :: MVar Bool
toolCommands :: Chan ToolCommand
toolCommandsRead :: Chan ToolCommand
currentToolCommand :: MVar ToolCommand

toolProcess :: ToolState -> IO ProcessHandle Source

newToolState :: IO ToolState Source

runTool :: MonadIO m => FilePath -> [String] -> Maybe FilePath -> IO (Enumerator ToolOutput m b, ProcessHandle)Source

runTool' :: FilePath -> [String] -> Maybe FilePath -> IO ([ToolOutput], ProcessHandle)Source

runInteractiveTool :: ToolState -> CommandLineReader -> FilePath -> [String] -> IO ()Source

newGhci :: [String] -> [String] -> Iteratee ToolOutput IO () -> IO ToolState Source

newGhci' :: [String] -> Iteratee ToolOutput IO () -> IO ToolState Source

executeCommand :: ToolState -> String -> String -> Iteratee ToolOutput IO () -> IO ()Source

executeGhciCommand :: ToolState -> String -> Iteratee ToolOutput IO () -> IO ()Source

quoteArg :: String -> String Source

escapeQuotes :: String -> String Source

runCommand :: String -> IO ProcessHandle

Runs a command using the shell.

waitForProcess :: ProcessHandle -> IO ExitCode

Waits for the specified process to terminate, and returns its exit code.

GHC Note: in order to call `waitForProcess` without blocking all the other threads in the system, you must compile the program with `-threaded`.

interruptProcessGroupOf

Arguments

:: ProcessHandle | A process in the process group
-> IO () |

Sends an interrupt signal to the process group of the given process.

On Unix systems, it sends the group the SIGINT signal.

On Windows systems, it generates a CTRL_BREAK_EVENT and will only work for processes created using `createProcess` and setting the `create_group` flag

data ProcessHandle

getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode)

This is a non-blocking version of `waitForProcess`. If the process is still running, `Nothing` is returned. If the process has exited, then ``Just` e` is returned where `e` is the exit code of the process.

runInteractiveProcess

Arguments

:: FilePath | Filename of the executable (see `proc` for details)
-> [String] | Arguments to pass to the executable
-> Maybe FilePath | Optional path to the working directory
-> Maybe [(String, String)] | Optional environment (otherwise inherit)
-> IO (Handle, Handle, Handle, ProcessHandle) |

Runs a raw command, and returns `Handle`s that may be used to communicate with the process via its `stdin`, `stdout` and `stderr` respectively.

For example, to start a process and feed a string to its stdin:

       (inp,out,err,pid) <- runInteractiveProcess "..."
       forkIO (hPutStr inp str)

The `Handle`s are initially in binary mode; if you need them to be in text mode then use `hSetBinaryMode`.

runProcess

Arguments

:: FilePath | Filename of the executable (see `proc` for details)
-> [String] | Arguments to pass to the executable
-> Maybe FilePath | Optional path to the working directory
-> Maybe [(String, String)] | Optional environment (otherwise inherit)
-> Maybe Handle | Handle to use for `stdin` (Nothing => use existing `stdin`)
-> Maybe Handle | Handle to use for `stdout` (Nothing => use existing `stdout`)
-> Maybe Handle | Handle to use for `stderr` (Nothing => use existing `stderr`)
-> IO ProcessHandle |

Runs a raw command, optionally specifying `Handle`s from which to take the `stdin`, `stdout` and `stderr` channels for the new process (otherwise these handles are inherited from the current process).

Any `Handle`s passed to `runProcess` are placed immediately in the closed state.

Note: consider using the more general `createProcess` instead of `runProcess`.