1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use Command;
use InnerCommand;
/// This is the lowest-level of the three apis.
/// It returns a channel which allows the caller to process all command output manually.
/// This API provides the most flexibility at the cost of the most work to the user.
/// ## Example:
/// ```
/// use currant::{ChannelCommand, Command, OutputMessagePayload, Runner, CURRENT_WORKING_DIRECTORY};
///
/// let handle = Runner::new()
/// .command(ChannelCommand::from_string("test1", "ls -la .", CURRENT_WORKING_DIRECTORY).unwrap())
/// .command(ChannelCommand::from_string("test2", "ls -la ..", CURRENT_WORKING_DIRECTORY).unwrap())
/// .command(ChannelCommand::from_string("test3", "ls -la ../..", CURRENT_WORKING_DIRECTORY).unwrap())
/// .execute();
///
/// for msg in &handle {
/// print!("{}: ", msg.name);
/// match msg.message {
/// OutputMessagePayload::Done(status) => println!("exited with status: {:?}", status),
/// OutputMessagePayload::Error(e) => println!("errored with message: {}", e),
/// OutputMessagePayload::Start => println!("Started"),
/// OutputMessagePayload::Stdout(_, bytes) => {
/// println!("stdout: {}", String::from_utf8_lossy(&bytes))
/// }
/// OutputMessagePayload::Stderr(_, bytes) => {
/// println!("stderr: {}", String::from_utf8_lossy(&bytes))
/// }
/// }
/// }
///
/// handle.join().unwrap();
/// ```
/// Also see `examples/main_channel.rs` for a full version