From b409f499915a427201fa850cbf3e2d513f143097 Mon Sep 17 00:00:00 2001 From: Charlotte Thomas Date: Mon, 22 Apr 2024 11:33:14 +0200 Subject: [PATCH] bump to 2.14.0 add update --- CHANGELOG.md | 3 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/configuration/loader.rs | 2 +- src/main.rs | 22 ++++++++++++++++++++-- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2b0091..a5d5c8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# Version 2.13.0 : Update! +You can upgrade the calculator with `mini-calc --update` + # Version 2.12.4 : Fix bug Fix the bug where the calculated vectors for plotting appeared when plotting diff --git a/Cargo.lock b/Cargo.lock index 95fdd35..2885861 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,7 +221,7 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mini-calc" -version = "2.12.4" +version = "2.13.0" dependencies = [ "ansi_term", "atty", diff --git a/Cargo.toml b/Cargo.toml index 0d3a889..8bba44e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mini-calc" -version = "2.12.4" +version = "2.13.0" license = "GPL-3.0-or-later" description = "A fully-featured minimalistic configurable rust calculator" homepage = "https://calc.nwa2coco.fr" diff --git a/src/configuration/loader.rs b/src/configuration/loader.rs index 6886346..5495f04 100644 --- a/src/configuration/loader.rs +++ b/src/configuration/loader.rs @@ -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.4") + .replace("%version%", "v2.13.0") .to_string() } diff --git a/src/main.rs b/src/main.rs index f415edd..0e65e98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::env::{self, Args}; use std::f64::consts::{E, PI}; -use std::process::exit; +use std::process::{exit, Command}; use std::str::SplitWhitespace; use std::sync::Arc; @@ -262,7 +262,7 @@ fn handle_config(line: &str, config: Config) -> (String, Option) { fn main() { let mut args: Args = env::args(); - let version: String = "v2.12.4".to_string(); + let version: String = "v2.13.0".to_string(); if args.len() > 1 || !atty::is(Stream::Stdin) { let mut a = vec![]; @@ -293,6 +293,24 @@ fn main() { exit(0); } + if arg_final == "-u" || arg_final == "--update" { + if cfg!(target_os = "windows") { + Command::new("cmd") + .args(["/C", "cargo install mini-calc --force"]) + .output() + .expect("update failed") + } else { + Command::new("sh") + .arg("-c") + .arg("cargo install mini-calc --force") + .output() + .expect("update failed") + }; + println!("mini-calc has been succesfully updated to the latest version"); + exit(0); + } + + let lexed = lex(arg_final); let mut parser = init_calc_parser(&lexed); let parsed = parser.parse();