allonsy / currant

A simple rust library to concurrently spawn shell processes
MIT License
4 stars 1 forks source link

make the output configurable #17

Closed kevgo closed 2 years ago

kevgo commented 2 years ago

Currently the output of Currant is hard-coded to look like this:

SYSTEM: starting process app1
app1: (output here)
app1: process exited with status: 0

It would be nice if the caller could configure it to look for example like this (assuming we run "make start" in a subshell):

app1: make start
app1: (output here)
app1 success

The API could use the existing String formatting facilities of Rust, in particular named parameters:

let mut runner = Runner::new();

// configure output of a line for all commands
// name and line are known to Currant
// line is a line of output from the subshell
runner.lineTemplate("{name}: {line}");

let command_str = "make start";
let mut cmd = ConsoleCommand::from_string(name, command_str).unwrap();

// override message before Currant starts this specific command
cmd.startTemplate("{name} {}", command_str);

// configure message when any task exits with code 0
runner.successTemplate("{name} success");

// configure message when any task exits with non-zero code
runner.failureTemplate("{name} failed, error code {exit_code}");
allonsy commented 2 years ago

Addressed with #26

allonsy commented 2 years ago

API is on the runner: runner.start_message_template runner.done_message_template runner.payload_message_template runner.error_message_template

allonsy commented 2 years ago

Closing with #26