diff options
author | Henrique Alves <henriquelalves@gmail.com> | 2022-07-26 11:16:51 -0300 |
---|---|---|
committer | Henrique Alves <henriquelalves@gmail.com> | 2022-07-26 11:16:51 -0300 |
commit | c4c208c15575e64907291d4567cd72d5ceb7c0ef (patch) | |
tree | 0e50ecaaa62a152de61ad8ebda2f06bf5a6f109b /src/utils.rs | |
parent | ef02e2bbd6e0bebfc39f21c1a790c8c06d856eb3 (diff) | |
download | glam-c4c208c15575e64907291d4567cd72d5ceb7c0ef.tar.gz glam-c4c208c15575e64907291d4567cd72d5ceb7c0ef.tar.bz2 glam-c4c208c15575e64907291d4567cd72d5ceb7c0ef.zip |
Asserting results form shell commands
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs index e925f9d..81bd63f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,6 @@ use colored::Colorize; use std::io::Write; +use std::process::exit; pub fn log_warning(msg: &str) { let msg = format!("⚠️ {}", msg).yellow(); @@ -21,6 +22,14 @@ pub fn log_check(msg: &str) { println!("{}", msg); } +pub fn assert_res(res : &Result<String, String>, error_msg : &str) { + if res.is_err() { + log_error(error_msg); + log_error(&format!("{:?}", res)); + exit(1); + } +} + pub fn get_repo_name(repo: &str) -> String { let mut chars = repo.chars().rev(); let length = repo.chars().count(); |