Skip to main content

Module process

Module process 

Source
Expand description

Running external programs from a command

Most command-line applications drive other programs. A release tool calls git, a build tool calls cargo, and a deployment tool calls a provider’s own client. This module defines Process, the interface that runs such a program and reports it through the event system while it runs.

A run reports itself as ProcessEvents: one for the start, one for every line that the program writes, and one for the end. A presenter therefore shows a long build as it happens, and a TUI can keep the last few lines of the program in a corner of the screen. The command’s own code is the same in both cases.

The description of a command is an Invocation, and the result of a run is an Execution. Both come from the kawauso-process crate, which owns the mechanics of starting a program and reading its streams. This module re-exports what a command names, so that an application needs Clawless alone.

§Examples

use clawless_core::process::{Invocation, Process};

let execution = process
    .run(Invocation::new("git").arg("status").arg("--short"))
    .await?
    .require_success()?;

let status = execution.stdout().to_string_lossy();

Structs§

Argument
One argument of an external command
Capture
The bytes that a command wrote to one of its streams
Execution
The result of one run of an external command
Invocation
The description of one external command
Line
One line of the output of a command
Process
Runs external programs and reports them through the event system
ProcessBuilder
Use builder syntax to set the inputs and finish with build().
ProcessId
The identifier that the operating system gives a command
Program
The program that an external command starts
Run
The run of a command that the caller observes while it runs
Text
The text of one line of output
WorkingDirectory
The directory in which an external command runs

Enums§

RequireSuccessError
The error returned when a command ended without success
RunCommandError
The error returned when a command does not run
RunProcessError
The error returned when a command cannot run an external program
Stream
The stream of a command that produced a line of output