mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-10 12:49:18 +00:00
feat(cli): adding colors in list command
This commit is contained in:
parent
5002c54ffb
commit
eccdc5bdf8
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -99,6 +99,17 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colored"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
|
||||||
|
dependencies = [
|
||||||
|
"atty",
|
||||||
|
"lazy_static",
|
||||||
|
"winapi 0.3.9",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "console"
|
name = "console"
|
||||||
version = "0.7.7"
|
version = "0.7.7"
|
||||||
@ -545,6 +556,7 @@ version = "4.6.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"argh",
|
"argh",
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
|
"colored",
|
||||||
"console 0.7.7",
|
"console 0.7.7",
|
||||||
"glob",
|
"glob",
|
||||||
"indicatif",
|
"indicatif",
|
||||||
|
|||||||
@ -12,6 +12,7 @@ notify = "4.0.15"
|
|||||||
toml = "0.4.10"
|
toml = "0.4.10"
|
||||||
regex = "1.1.6"
|
regex = "1.1.6"
|
||||||
serde = {version = "1.0.10", features = ["derive"]}
|
serde = {version = "1.0.10", features = ["derive"]}
|
||||||
|
colored = "2.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "rustlings"
|
name = "rustlings"
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use crate::exercise::{Exercise, ExerciseList};
|
|||||||
use crate::run::run;
|
use crate::run::run;
|
||||||
use crate::verify::verify;
|
use crate::verify::verify;
|
||||||
use argh::FromArgs;
|
use argh::FromArgs;
|
||||||
|
use colored::Colorize;
|
||||||
use console::Emoji;
|
use console::Emoji;
|
||||||
use notify::DebouncedEvent;
|
use notify::DebouncedEvent;
|
||||||
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
||||||
@ -163,6 +164,7 @@ fn main() {
|
|||||||
} else {
|
} else {
|
||||||
"Pending"
|
"Pending"
|
||||||
};
|
};
|
||||||
|
let line_color = if status == "Done" { "green" } else { "red" };
|
||||||
let solve_cond = {
|
let solve_cond = {
|
||||||
(e.looks_done() && subargs.solved)
|
(e.looks_done() && subargs.solved)
|
||||||
|| (!e.looks_done() && subargs.unsolved)
|
|| (!e.looks_done() && subargs.unsolved)
|
||||||
@ -174,7 +176,12 @@ fn main() {
|
|||||||
} else if subargs.names {
|
} else if subargs.names {
|
||||||
format!("{}\n", e.name)
|
format!("{}\n", e.name)
|
||||||
} else {
|
} else {
|
||||||
format!("{:<17}\t{:<46}\t{:<7}\n", e.name, fname, status)
|
format!(
|
||||||
|
"{:<17}\t{:<46}\t{:<7}\n",
|
||||||
|
e.name.color(line_color),
|
||||||
|
fname.color(line_color),
|
||||||
|
status.color(line_color)
|
||||||
|
)
|
||||||
};
|
};
|
||||||
// Somehow using println! leads to the binary panicking
|
// Somehow using println! leads to the binary panicking
|
||||||
// when its output is piped.
|
// when its output is piped.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user