Added some colours to the terminal output.

This commit is contained in:
PaddiM8 2020-05-30 15:59:25 +02:00
parent 036fadb041
commit 2b90620d83
3 changed files with 15 additions and 3 deletions

10
Cargo.lock generated
View File

@ -1,5 +1,14 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "arrayref"
version = "0.3.6"
@ -113,6 +122,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
name = "lek"
version = "0.1.0"
dependencies = [
"ansi_term",
"phf",
"rustyline",
]

View File

@ -13,3 +13,4 @@ panic = "abort"
[dependencies]
rustyline = "6.1.2"
phf = { version = "0.8", features = ["macros"] }
ansi_term = "0.12"

View File

@ -7,9 +7,10 @@ mod parser;
mod prelude;
mod symbol_table;
use ansi_term::Colour::{Cyan, Red};
use ast::Unit;
use rustyline::error::ReadlineError;
use rustyline::Editor;
use ast::Unit;
fn main() {
let mut parser = parser::Context::new();
@ -24,7 +25,7 @@ fn main() {
let mut rl = Editor::<()>::new();
loop {
let readline = rl.readline(">> ");
let readline = rl.readline(&Cyan.paint(">> ").to_string());
match readline {
Ok(input) => {
@ -50,7 +51,7 @@ fn eval(parser: &mut parser::Context, input: &str) {
match parser::parse(parser, input, get_angle_unit()) {
Ok(Some(result)) => println!("{}", result),
Ok(None) => print!(""),
Err(err) => println!("{}", err),
Err(err) => println!("{}", Red.paint(err)),
}
}