Skip to main content

cargo_cbt/
sh.rs

1use crate::errors::*;
2use iocore::Path;
3
4pub fn shell_command(command: impl std::fmt::Display, current_dir: impl Into<Path>) -> Result<i32> {
5    let command = command.to_string();
6    eprintln!("running {:#?}", &command);
7    match iocore::shell_command(&command, current_dir) {
8        Ok(exit_code) => {
9            if exit_code != 0 {
10                Err(Error::CliError(format!(
11                    "command {:#?} failed with exit code {}",
12                    &command, exit_code
13                )))
14            } else {
15                Ok(exit_code)
16            }
17        }
18        Err(error) => Err(Error::CliError(format!(
19            "command {:#?} failed with error: {}",
20            &command, error
21        ))),
22    }
23}