Fix step logging

This commit is contained in:
Michael Pfaff 2022-06-10 13:30:48 -04:00
parent ceeaed0b8d
commit bc44b249f4
Signed by: michael
GPG Key ID: CF402C4A012AA9D4
1 changed files with 18 additions and 1 deletions

View File

@ -73,7 +73,10 @@ impl<'a> Step<'a> {
match self {
Self::DownloadFile { res, file } => {
if file.exists() {
println!("File {file} already downloaded.");
println!(
"File {file} already downloaded.",
file = file.to_str().unwrap_or("<NON UTF-8>")
);
} else {
println!(
"Downloading file {file} from {res:?}...",
@ -147,6 +150,11 @@ impl<'a> Step<'a> {
}
}
Self::ExtractFile { file, dest } => {
println!(
"Extracting {file} to {dest}...",
file = file.to_str().unwrap_or("<NON UTF-8>"),
dest = dest.to_str().unwrap_or("<NON UTF-8>")
);
const EXTRACT_FILE_ERROR_MSG: &'static str = "Extracting file failed.";
mkdir_all(&dest).await.wrap_err(EXTRACT_FILE_ERROR_MSG)?;
let dest = tokio::fs::canonicalize(&dest)
@ -166,6 +174,11 @@ impl<'a> Step<'a> {
ensure!(status.success(), EXTRACT_FILE_ERROR_MSG);
}
Self::ExecuteCommand { file, args } => {
println!(
"Executing command `{file} {args}`...",
file = file.to_str().unwrap_or("<NON UTF-8>"),
args = args.into_iter().map(|s| *s).collect::<String>(),
);
const EXECUTE_COMMAND_ERROR_MSG: &'static str = "Executing command failed.";
let status = tokio::process::Command::new(file.as_os_str())
.args(*args)
@ -178,6 +191,10 @@ impl<'a> Step<'a> {
ensure!(status.success(), EXECUTE_COMMAND_ERROR_MSG);
}
Self::CreateShortcut { target, file } => {
println!(
"Creating shortcut to {target:?} at {file}...",
file = file.to_str().unwrap_or("<NON UTF-8>")
);
const CREATE_SHORTCUT_ERROR_MSG: &'static str = "Creating shortcut failed.";
mkdir_all(
file.parent().ok_or_else(|| {