Skip to content

Commit

Permalink
Add Colors
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbate19 committed Mar 4, 2022
1 parent 681e722 commit e466435
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/commands/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ pub fn list(matches: &ArgMatches<'_>, api: &mut API) -> Result<(), Box<dyn std::
None => return Err(Box::new(APIError::BadFormat)),
};
let subject_line = format!("{} ({})", display_name, name);
println!("{}", &subject_line);
println!("{}", "=".repeat(subject_line.len()));
println!("\n\x1B[36m{}\x1B[0m", &subject_line);
println!("\x1B[36m{}\x1B[0m", "=".repeat(subject_line.len()));
let slots: &Vec<Value> = match machine["slots"].as_array() {
Some(slots) => slots,
None => return Err(Box::new(APIError::BadFormat)),
Expand All @@ -66,9 +66,10 @@ pub fn list(matches: &ArgMatches<'_>, api: &mut API) -> Result<(), Box<dyn std::
let price = item["price"].as_u64().unwrap();
let slot_number = slot["number"].as_u64().unwrap();
let name = item["name"].as_str().unwrap();
print!("{}. {} ({} Credits)", slot_number, name, price);
if slot["empty"].as_bool().unwrap() {
print!(" [EMPTY]");
print!("\x1B[31m{}. {} ({} Credits) [EMPTY]\x1B[0m", slot_number, name, price)
} else {
print!("{}. {} ({} Credits)", slot_number, name, price)
}
println!("");
}
Expand Down

0 comments on commit e466435

Please sign in to comment.