Skip to content

Commit

Permalink
Hotfix (#40)
Browse files Browse the repository at this point in the history
* bump to 2.12.3

add piping to the calculator
add version to the non interactive version

* add changelog
  • Loading branch information
coco33920 authored Apr 12, 2024
1 parent df1421b commit 12aec98
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Version 2.12.3 : Piping
Piping has been added to the calculator

# Version 2.12.2 : Non interactive use
Added non interactive use

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mini-calc"
version = "2.12.2"
version = "2.12.3"
license = "GPL-3.0-or-later"
description = "A fully-featured minimalistic configurable rust calculator"
homepage = "https://calc.nwa2coco.fr"
Expand All @@ -22,7 +22,7 @@ linefeed = "0.6"
confy = "0.5.1"
gnuplot = "0.0.39"
serde = { version = "1.0.192", features = ["derive"] }

atty = "0.2"
# Config for 'cargo dist'
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn load_color(string: String) -> Color {

pub fn replace_variable(str: String) -> String {
str.replace("%author%", "Charlotte Thomas")
.replace("%version%", "v2.12.2")
.replace("%version%", "v2.12.3")
.to_string()
}

Expand Down
28 changes: 21 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ use crate::interpreting::interpreter::interpret;
use crate::lexing::lexer::lex;
use crate::parsing::ast::{Ast, Parameters};
use crate::parsing::parser::{init_calc_parser, CalcParser};
use atty::Stream;
use std::io;
use std::io::BufRead;

mod configuration;
mod exact_math;
Expand Down Expand Up @@ -258,15 +261,23 @@ fn handle_config(line: &str, config: Config) -> (String, Option<Config>) {

fn main() {
let mut args: Args = env::args();
if args.len() > 1 {
args.nth(0);

let version: String = "v2.12.3".to_string();
if args.len() > 1 || !atty::is(Stream::Stdin) {
let mut a = vec![];
args.for_each(|f| a.push(f));
let arg_final = a.join("");

if !atty::is(Stream::Stdin) {
let stdin = io::stdin();
for line in stdin.lock().lines() {
a.push(line.unwrap().to_string());
}
} else {
args.nth(0);
args.for_each(|f| a.push(f));
}

let arg_final = a.join("");
if arg_final == "-h" || arg_final == "--help" {

println!("-----Help Calc-----");
println!("");
println!("mini-calc > launch the mini-calc REPL");
Expand All @@ -275,9 +286,13 @@ fn main() {
println!("");
println!("------Help Calc-----");
exit(0);

}

if arg_final == "-v" || arg_final == "--version" {
println!("Calc {version}");
exit(0);
}

let lexed = lex(arg_final);
let mut parser = init_calc_parser(&lexed);
let parsed = parser.parse();
Expand Down Expand Up @@ -317,7 +332,6 @@ fn main() {
let style = &loaded.clone().prompt_style;
let mut text = &loaded.clone().prompt;
let mut verbose = false;
let version: String = "v2.12.2".to_string();
interface.set_completer(Arc::new(CalcCompleter));
interface
.set_prompt(&format!(
Expand Down

0 comments on commit 12aec98

Please sign in to comment.