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
pub mod args;
pub mod exec;
pub mod print_title;

use super::{github_actions, PrettyExec, SyntaxHighLight};
use std::env;

pub use std::process::ExitStatus;

pub struct Param<'a> {
    pub program: &'a str,
    pub arguments: &'a [String],
    pub skip_exec: bool,
    pub syntax_highlight: SyntaxHighLight<String>,
    pub support_github_action: bool,
}

pub fn main() -> Result<i32, String> {
    let args = args::Args::get(env::args());
    let param = args.param();

    if param.skip_exec {
        print_title::print_title(param);
        return Ok(0);
    }

    exec::exec(param).and_then(|status| {
        status
            .code()
            .ok_or_else(|| "Failed to get status code".to_owned())
    })
}