File tree Expand file tree Collapse file tree 4 files changed +183
-11
lines changed Expand file tree Collapse file tree 4 files changed +183
-11
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " csc"
3
- version = " 0.1.2 "
3
+ version = " 0.1.3 "
4
4
edition = " 2021"
5
5
authors = [" Zahash <zahash.z@gmail.com>" ]
6
6
description = " Command Line Scientific Calculator"
@@ -10,6 +10,7 @@ repository = "https://github.com/zahash/csc"
10
10
[dependencies ]
11
11
regex = { version = " 1" }
12
12
lazy_static = { version = " 1" }
13
+ clap = { version = " 4" , features = [" derive" ] }
13
14
rustyline = { version = " 12" }
14
15
15
16
[dev-dependencies ]
Original file line number Diff line number Diff line change 1
1
<div align =" center " >
2
2
3
- # csc
3
+ <pre >
4
+ ██████╗███████╗ ██████╗
5
+ ██╔════╝██╔════╝██╔════╝
6
+ ██║ ███████╗██║
7
+ ██║ ╚════██║██║
8
+ ╚██████╗███████║╚██████╗
9
+ ╚═════╝╚══════╝ ╚═════╝
10
+ ------------------------
11
+ Command Line Scientific Calculator. Free Forever. Made with ❤️ using 🦀
12
+ </pre >
4
13
5
14
[ ![ Crates.io] ( https://img.shields.io/crates/v/csc.svg )] ( https://crates.io/crates/csc )
6
15
[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
7
16
8
17
</div >
9
18
10
- > Command Line Scientific Calculator.
11
-
12
19
## Download
13
20
14
21
[ https://github.com/zahash/csc/releases ] ( https://github.com/zahash/csc/releases )
15
22
23
+ ( or )
24
+
25
+ ```
26
+ cargo install csc
27
+ ```
28
+
16
29
## Usage examples
17
30
18
31
``` sh
@@ -36,4 +49,3 @@ Distributed under the MIT license. See `LICENSE` for more information.
36
49
3 . Commit your changes (` git commit -am 'Add some fooBar' ` )
37
50
4 . Push to the branch (` git push origin feature/fooBar ` )
38
51
5 . Create a new Pull Request
39
-
Original file line number Diff line number Diff line change 1
1
use crate :: eval:: * ;
2
2
3
+ use clap:: Parser ;
3
4
use rustyline:: error:: ReadlineError ;
4
5
5
6
const LOGO : & ' static str = r#"
6
- ███████ ██████ ██ ██████ █████ ██ ██████
7
- ██ ██ ██ ██ ██ ██ ██ ██
8
- ███████ ██ ██ ██ ███████ ██ ██
9
- ██ ██ ██ ██ ██ ██ ██ ██
10
- ███████ ██████ ██ ██████ ██ ██ ███████ ██████
7
+ ██████ ███████ ██████
8
+ ██ ██ ██
9
+ ██ ████ ███ ██
10
+ ██ ██ ██
11
+ ██████ ███████ ██ ████
11
12
"# ;
12
13
14
+ /// CSC
15
+ #[ derive( Parser ) ]
16
+ struct Cli {
17
+ /// run one off computations instead of launching the prompt
18
+ expr : Option < Vec < String > > ,
19
+ }
20
+
13
21
pub fn run ( ) {
22
+ if let Some ( expr) = Cli :: parse ( ) . expr {
23
+ let expr = expr. join ( " " ) ;
24
+ match eval ( expr. as_str ( ) , & mut State :: new ( ) ) {
25
+ Ok ( res) => println ! ( "{}" , res) ,
26
+ Err ( e) => eprintln ! ( "{:?}" , e) ,
27
+ }
28
+ return ;
29
+ }
30
+
14
31
println ! ( "{}" , LOGO ) ;
15
32
println ! ( env!( "CARGO_PKG_VERSION" ) ) ;
16
33
You can’t perform that action at this time.
0 commit comments