Update to 0.4.1

- Multiple argument handling.

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
Ivan Bushchik 2023-05-31 10:50:08 +03:00
parent 053e938d32
commit 740d0b6dd4
No known key found for this signature in database
GPG key ID: 9F6DDABE11A2674D
3 changed files with 23 additions and 23 deletions

3
.gitignore vendored
View file

@ -1,2 +1,3 @@
/target /target
Cargo.lock Cargo.lock
.idea

View file

@ -1,6 +1,6 @@
[package] [package]
name = "feval" name = "feval"
version = "0.4.0" version = "0.4.1"
edition = "2021" edition = "2021"
description = "clt for fast evaluations" description = "clt for fast evaluations"
readme = "README.md" readme = "README.md"

View file

@ -13,7 +13,7 @@ mod tasks;
fn help() { fn help() {
println!( println!(
r#"feval: help r#"feval: help
usage: provide exactly one argument (with expression) or no arguments for shell mode. usage: provide expression as arguments or don't provide arguments for shell mode.
example: feval "math::sin(30 * math::pi / 180)""# example: feval "math::sin(30 * math::pi / 180)""#
); );
} }
@ -37,27 +37,26 @@ fn main_loop() {
fn main() { fn main() {
let args: Vec<String> = args().collect(); let args: Vec<String> = args().collect();
match args.len() { if args.contains(&"--help".to_string()) {
2 => { help();
let expr = all(args[1].clone()); std::process::exit(0);
let result = evalexpr::eval(&expr.trim()); }
match result { if args.len() >= 2 {
Ok(succ_res) => println!("{}", succ_res), let mut expr = String::new();
Err(err) => { for i in args[1..].to_vec() {
println!("Error: {}", err); expr += &i;
std::process::exit(127); expr += " ";
} }
} let expr = all(expr);
} let result = evalexpr::eval(&expr.trim());
1 => main_loop(), match result {
_ => { Ok(succ_res) => println!("{}", succ_res),
if args.len() > 2 { Err(err) => {
println!("Too many args."); println!("Error: {}", err);
help(); std::process::exit(127);
} else if args.len() < 1 {
println!("Too few args.");
help();
} }
} }
} else if args.len() == 1 {
main_loop();
} }
} }