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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*!
This crate provides a library for executing system commands.

# Usage

This crate is [on crates.io](https://crates.io/crates/reef) and can be
used by adding `reef` to your dependencies in your project's `Cargo.toml`.

```toml
[dependencies]
reef = "0"
```

If you're using Rust 2015, then you'll also need to add it to your crate root:

```rust
extern crate reef;
```

# Example: execute a command that is in the system PATH

note: git must be available in the system PATH for this example to work.

```rust
use reef::Command;
let git_version = Command::new("git --version",&std::env::temp_dir()).exec().unwrap();
assert!(git_version.stdout.contains("git version"));
```

*/

#![crate_name = "reef"]
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::path::PathBuf;
use std::time::Duration;

#[macro_use]
extern crate error_chain;
pub mod duration;
mod errors;
mod path;
// #region Structs
// #region struct Env
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
/// Metadata about the environment
pub struct Env {
    /// The username
    pub username: String,
    /// The hostname,
    pub hostname: String,
    /// The distro
    pub distro: String,
    /// The real name for the user
    pub realname: String,
    /// The device name
    pub devicename: String,
}
mod env;
// #endregion struct Env

// #region struct Command
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)]
/// Metadata about a std::process::Command
pub struct Command {
    /// The working directory
    pub dir: PathBuf,
    /// The command name
    pub name: String,
    /// The command arguments
    pub args: Vec<String>,
    /// The standard output text
    pub stdout: String,
    /// The standard error text
    pub stderr: String,
    /// Indication of success or failure
    pub success: bool,
    /// The exit code of the process
    pub exit_code: i32,
    /// The duration of the command execution
    pub duration: Duration,
    /// The timeout duration for the command execution
    pub timeout: Duration,
    /// The start time of the command execution
    pub start: String,
    /// Environment metadata
    pub env: Env,
    /// Tags
    pub tags: HashSet<String>,
    /// UUID
    pub uuid: String,
}
mod command;
// #endregion struct Command
// #endregion Structs