pretty_exec_lib/app/
exec.rs

1use super::{github_actions, Error, ExitStatus, Param, PrettyExec};
2
3pub fn exec(param: Param) -> Result<ExitStatus, Error> {
4    let Param {
5        program,
6        arguments,
7        prompt,
8        syntax_highlight,
9        support_github_action,
10        ..
11    } = param;
12    let pretty_exec = PrettyExec::new(prompt, program, arguments);
13
14    let exec_result = if support_github_action {
15        pretty_exec
16            .set_log_before(github_actions::GroupOpening::from(syntax_highlight))
17            .set_log_after(github_actions::GroupClosing)
18            .spawn()
19    } else {
20        pretty_exec.set_log_before(syntax_highlight).spawn()
21    };
22
23    exec_result.map_err(Error::ExecutionError)
24}