changed fail symbol and added a prompt symbol
This commit is contained in:
parent
04dacdb562
commit
06a24c6a7d
1 changed files with 10 additions and 3 deletions
13
src/main.rs
13
src/main.rs
|
@ -1,6 +1,11 @@
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
io::stdin
|
io::{
|
||||||
|
stdin,
|
||||||
|
stdout,
|
||||||
|
|
||||||
|
Write
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
use evalexpr::{
|
use evalexpr::{
|
||||||
|
@ -20,6 +25,8 @@ fn main() {
|
||||||
if expressions.len() == 0 {
|
if expressions.len() == 0 {
|
||||||
println!("{}quickmaths v0.1.2{}\n{}Interactive Mode{}", style::Bold, style::Reset, style::Faint, style::Reset);
|
println!("{}quickmaths v0.1.2{}\n{}Interactive Mode{}", style::Bold, style::Reset, style::Faint, style::Reset);
|
||||||
loop {
|
loop {
|
||||||
|
print!("> ");
|
||||||
|
stdout().flush().unwrap();
|
||||||
let mut i_line = String::new();
|
let mut i_line = String::new();
|
||||||
let line_result = stdin().read_line(&mut i_line);
|
let line_result = stdin().read_line(&mut i_line);
|
||||||
if line_result.is_err() {
|
if line_result.is_err() {
|
||||||
|
@ -44,7 +51,7 @@ fn do_eval(i_expression: String, context: &mut HashMapContext) -> (String, Optio
|
||||||
let expression = i_expression.as_str();
|
let expression = i_expression.as_str();
|
||||||
let i_result = eval_with_context_mut(expression, context);
|
let i_result = eval_with_context_mut(expression, context);
|
||||||
if i_result.is_err() {
|
if i_result.is_err() {
|
||||||
return (format!("{}🞪 {}{}", color::Fg(color::Red), style::Bold, expression), None);
|
return (format!("{}✕ {}{}", color::Fg(color::Red), style::Bold, expression), None);
|
||||||
}
|
}
|
||||||
let result = i_result.ok().unwrap();
|
let result = i_result.ok().unwrap();
|
||||||
if result.is_empty() {
|
if result.is_empty() {
|
||||||
|
@ -53,7 +60,7 @@ fn do_eval(i_expression: String, context: &mut HashMapContext) -> (String, Optio
|
||||||
let delimiter;
|
let delimiter;
|
||||||
match result {
|
match result {
|
||||||
Value::Boolean(_bool) => delimiter = "is",
|
Value::Boolean(_bool) => delimiter = "is",
|
||||||
Value::String(ref _str) => delimiter = "=>",
|
Value::String(ref _str) => delimiter = "=>",
|
||||||
_ => delimiter = "="
|
_ => delimiter = "="
|
||||||
}
|
}
|
||||||
return (format!("{}{}{}{} {} {}{}", style::Faint, style::Italic, expression, style::Reset, delimiter, style::Bold, result), Some(result));
|
return (format!("{}{}{}{} {} {}{}", style::Faint, style::Italic, expression, style::Reset, delimiter, style::Bold, result), Some(result));
|
||||||
|
|
Loading…
Reference in a new issue