Skip to content

Commit

Permalink
print stderr with style for caps
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed May 24, 2024
1 parent 9ec0acb commit 94e7d5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/bin/calcit_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn download_deps(deps: HashMap<Arc<str>, Arc<str>>, options: &CliArgs) -> Result
let ret = thread::spawn(move || {
let ret = handle_path(modules_dir, version, options, org_and_folder);
if let Err(e) = ret {
eprintln!("Thread error: {}", e);
err_println(format!("{}\n", e));
}
});
children.push(ret);
Expand Down Expand Up @@ -256,7 +256,7 @@ fn err_println(msg: String) {
if msg.chars().nth(1) == Some(' ') {
println!("{}", msg.truecolor(255, 80, 80));
} else {
println!(" {}", msg.truecolor(255, 80, 80));
println!(" {}", msg.replace('\n', "\n ").truecolor(255, 80, 80));
}
}

Expand All @@ -266,7 +266,7 @@ fn gray(msg: &str) -> ColoredString {

fn indent4(msg: &str) -> String {
let ret = msg.lines().map(|line| format!(" {}", line)).collect::<Vec<String>>().join("\n");
format!("\n{}\n", ret)
format!("\n{}\n", ret.trim())
}

/// calcit dynamic libs uses a `build.sh` script to build Rust `.so` files
Expand Down
27 changes: 14 additions & 13 deletions src/bin/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub fn git_checkout(dir: &PathBuf, version: &str) -> Result<(), String> {
.output()
.map_err(|e| e.to_string())?;
if !output.status.success() {
// println!("output: {:?}", output);
Err(format!("failed to checkout {} {}", dir.to_str().unwrap(), version))
let err = String::from_utf8(output.stderr).expect("stderr");
Err(format!("{}\nfailed to checkout {} {}", err.trim(), dir.to_str().unwrap(), version))
} else {
Ok(())
}
Expand Down Expand Up @@ -38,8 +38,8 @@ pub fn git_clone(dir: &PathBuf, url: &str, version: &str, shallow: bool) -> Resu
.map_err(|e| e.to_string())?
};
if !output.status.success() {
// println!("output: {:?}", output);
Err(format!("failed to clone {} {}", url, version))
let err = String::from_utf8(output.stderr).expect("stderr");
Err(format!("{}\nfailed to clone {} {}", err.trim(), url, version))
} else {
Ok(())
}
Expand Down Expand Up @@ -68,8 +68,8 @@ pub fn git_current_head(dir: &PathBuf) -> Result<GitHead, String> {
.output()
.map_err(|e| e.to_string())?;
if !output.status.success() {
println!("output: {:?}", output);
Err(format!("failed to get current head of {}", dir.to_str().unwrap()))
let err = String::from_utf8(output.stderr).expect("stderr");
Err(format!("{}\nfailed to get current head of {}", err.trim(), dir.to_str().unwrap()))
} else {
let mut branch = String::from_utf8(output.stdout).map_err(|e| e.to_string())?;
branch = branch.trim().to_string();
Expand Down Expand Up @@ -100,7 +100,8 @@ pub fn git_check_branch_or_tag(dir: &PathBuf, version: &str) -> Result<bool, Str
.output()
.map_err(|e| e.to_string())?;
if !output.status.success() {
Ok(false)
let err = String::from_utf8(output.stderr).expect("stderr");
Err(format!("{}\nfailed to get current head of {}", err.trim(), dir.to_str().unwrap()))
} else {
Ok(true)
}
Expand All @@ -118,8 +119,8 @@ pub fn git_fetch(dir: &PathBuf) -> Result<(), String> {
.output()
.map_err(|e| e.to_string())?;
if !output.status.success() {
// println!("output: {:?}", output);
Err(format!("failed to fetch {}", dir.to_str().unwrap()))
let err = String::from_utf8(output.stderr).expect("stderr");
Err(format!("{}\nfailed to fetch {}", err.trim(), dir.to_str().unwrap()))
} else {
Ok(())
}
Expand All @@ -133,8 +134,8 @@ pub fn git_describe_tag(dir: &PathBuf) -> Result<String, String> {
.output()
.map_err(|e| e.to_string())?;
if !output.status.success() {
// println!("output: {:?}", output);
Err(format!("failed to get current tag of {}", dir.to_str().unwrap()))
let err = String::from_utf8(output.stderr).expect("stderr");
Err(format!("{}\nfailed to get current tag of {}", err.trim(), dir.to_str().unwrap()))
} else {
let mut tag = String::from_utf8(output.stdout).map_err(|e| e.to_string())?;
tag = tag.trim().to_string();
Expand All @@ -151,8 +152,8 @@ pub fn git_pull(dir: &PathBuf, branch: &str) -> Result<(), String> {
.output()
.map_err(|e| e.to_string())?;
if !output.status.success() {
// println!("output: {:?}", output);
Err(format!("failed to pull {} {}", dir.to_str().unwrap(), branch))
let err = String::from_utf8(output.stderr).expect("stderr");
Err(format!("{}\nfailed to pull {} {}", err.trim(), dir.to_str().unwrap(), branch))
} else {
Ok(())
}
Expand Down

0 comments on commit 94e7d5d

Please sign in to comment.