Skip to content

Commit e466435

Browse files
committed
Add Colors
1 parent 681e722 commit e466435

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/commands/list.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ pub fn list(matches: &ArgMatches<'_>, api: &mut API) -> Result<(), Box<dyn std::
4646
None => return Err(Box::new(APIError::BadFormat)),
4747
};
4848
let subject_line = format!("{} ({})", display_name, name);
49-
println!("{}", &subject_line);
50-
println!("{}", "=".repeat(subject_line.len()));
49+
println!("\n\x1B[36m{}\x1B[0m", &subject_line);
50+
println!("\x1B[36m{}\x1B[0m", "=".repeat(subject_line.len()));
5151
let slots: &Vec<Value> = match machine["slots"].as_array() {
5252
Some(slots) => slots,
5353
None => return Err(Box::new(APIError::BadFormat)),
@@ -66,9 +66,10 @@ pub fn list(matches: &ArgMatches<'_>, api: &mut API) -> Result<(), Box<dyn std::
6666
let price = item["price"].as_u64().unwrap();
6767
let slot_number = slot["number"].as_u64().unwrap();
6868
let name = item["name"].as_str().unwrap();
69-
print!("{}. {} ({} Credits)", slot_number, name, price);
7069
if slot["empty"].as_bool().unwrap() {
71-
print!(" [EMPTY]");
70+
print!("\x1B[31m{}. {} ({} Credits) [EMPTY]\x1B[0m", slot_number, name, price)
71+
} else {
72+
print!("{}. {} ({} Credits)", slot_number, name, price)
7273
}
7374
println!("");
7475
}

0 commit comments

Comments
 (0)