history: Nicer messages for undo result

It includes more details such as:
- What action was undone
- What item was affected in the action
- What that action involved
This commit is contained in:
Lux Aliaga 2022-11-03 21:06:28 -03:00
parent 19aa1955c8
commit 1cbfc5a568
Signed by: lux
GPG Key ID: B56C805968637437
1 changed files with 47 additions and 1 deletions

View File

@ -59,7 +59,53 @@ pub fn undo() -> Result<()> {
_ => bail!("Illegal action".red()),
}
println!("{}", "Last action undone".green());
println!(
"✅ {}",
format!(
"{}{}{}",
match contents[3] {
"take" => "Take",
"drop" => "Drop",
"switch" => "Switch",
_ => "Unknown",
}
.bold(),
" action undone".green(),
match contents[3] {
"take" => format!(
"{}{}{}{}{}{}{}",
" (".green(),
contents[1].bold(),
", from ".green(),
contents[0],
" to ".green(),
match contents[2] {
"active" => contents[2].green(),
"inactive" => contents[2].blue(),
_ => contents[2].red(),
}
.bold(),
" slot)".green(),
),
"drop" => format!(
"{}{}{}{}{}{}{}",
" (".green(),
contents[1].bold(),
", from ".green(),
match contents[2] {
"active" => contents[2].green(),
"inactive" => contents[2].blue(),
_ => contents[2].red(),
}
.bold(),
" slot to ".green(),
contents[0],
")".green(),
),
_ => String::from(""),
}
)
);
Ok(())
}