From f8ec8a7e2ed1910d33126c0a138bfe5c04c3e2f1 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 11 Jan 2026 23:15:25 +0800 Subject: [PATCH] feat: v1.1.6 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/list.rs | 23 ++++++++++++++++++++++- src/main.rs | 13 ++++++++++--- src/script.help.dart.txt | 2 +- src/script.help.go.txt | 2 +- src/script.help.rs.txt | 2 +- src/script.help.ts.txt | 2 +- 8 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c78a18..c7111d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1221,7 +1221,7 @@ dependencies = [ [[package]] name = "runrs" -version = "1.1.5" +version = "1.1.6" dependencies = [ "argh", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 05603b0..06203ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runrs" -version = "1.1.5" +version = "1.1.6" edition = "2018" license = "MIT/Apache-2.0" description = "A Tool for Run Rust Scripts" diff --git a/src/list.rs b/src/list.rs index e7d7dd6..5fef7e6 100644 --- a/src/list.rs +++ b/src/list.rs @@ -1,10 +1,16 @@ +use crate::install::install_scripts; use crate::util; use std::fs; use std::path::PathBuf; -pub fn list_scripts(script_repo: &Option, filter: Option<&String>) { +pub fn list_scripts( + script_repo: &Option, + filter: Option<&String>, + update_listed_scripts: bool, +) { let script_meta_map = util::fetch_script_meta_or_die(script_repo); + let mut matched_need_update_scripts = vec![]; let mut messages = vec![]; for script_meta in script_meta_map.values() { let script_name = &script_meta.script_name; @@ -34,6 +40,9 @@ pub fn list_scripts(script_repo: &Option, filter: Option<&String>) { ".".repeat(iff!(padding_length < 1, 1, padding_length)), script_size, )); + if is_script_exists && !is_script_matches { + matched_need_update_scripts.push(script_meta.script_name.clone()); + } } if filter.is_some() { messages.insert( @@ -48,4 +57,16 @@ pub fn list_scripts(script_repo: &Option, filter: Option<&String>) { messages.insert(0, format!("Found {} script(s):", script_meta_map.len())); } success!("{}", messages.join("\n")); + + if update_listed_scripts { + if matched_need_update_scripts.len() > 0 { + information!( + "Update listed scripts ON:\n- {}\n", + matched_need_update_scripts.join("\n- ") + ); + install_scripts(script_repo, &matched_need_update_scripts); + } else { + information!("No update listed scripts"); + } + } } diff --git a/src/main.rs b/src/main.rs index 054bfd9..56c88a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,11 +8,11 @@ mod help; mod install; mod list; mod run_rs; +#[cfg(feature = "switch-ts-lang")] +mod run_ts; mod template; mod util; mod verify; -#[cfg(feature = "switch-ts-lang")] -mod run_ts; #[derive(FromArgs, PartialEq, Debug)] /// Run script @@ -29,6 +29,9 @@ struct RunScriptArgs { /// install script #[argh(switch, short = 'i')] install: bool, + /// update listed scripts + #[argh(option)] + update_listed_scripts: Option, /// script repo #[argh(option, short = 'R')] script_repo: Option, @@ -59,7 +62,11 @@ fn main() { return; } if rs_args.list { - list::list_scripts(&rs_args.script_repo, rs_args.arguments.first()); + list::list_scripts( + &rs_args.script_repo, + rs_args.arguments.first(), + rs_args.update_listed_scripts.unwrap_or(false), + ); return; } if rs_args.install { diff --git a/src/script.help.dart.txt b/src/script.help.dart.txt index 84ff061..7049a7e 100644 --- a/src/script.help.dart.txt +++ b/src/script.help.dart.txt @@ -7,7 +7,7 @@ Show template: $ rundart -t|--template [--output script.dart] Show scriptions: -$ rundart -l|--list [filter] +$ rundart -l|--list [filter] [--update-listed-scripts] Install script: $ rundart -i|--install diff --git a/src/script.help.go.txt b/src/script.help.go.txt index 26213e5..e0d3948 100644 --- a/src/script.help.go.txt +++ b/src/script.help.go.txt @@ -7,7 +7,7 @@ Show template: $ rungo -t|--template [--output script.go] Show scriptions: -$ rungo -l|--list [filter] +$ rungo -l|--list [filter] [--update-listed-scripts] Install script: $ rungo -i|--install diff --git a/src/script.help.rs.txt b/src/script.help.rs.txt index 685c48f..4b3b97e 100644 --- a/src/script.help.rs.txt +++ b/src/script.help.rs.txt @@ -7,7 +7,7 @@ Show template: $ runrs -t|--template [--output script.rs] Show scriptions: -$ runrs [-R|--script-repo runrs] -l|--list [filter] +$ runrs [-R|--script-repo runrs] -l|--list [filter] [--update-listed-scripts] Install script: $ runrs [-R|--script-repo runrs] -i|--install diff --git a/src/script.help.ts.txt b/src/script.help.ts.txt index c04b3f2..cbb8cf9 100644 --- a/src/script.help.ts.txt +++ b/src/script.help.ts.txt @@ -7,7 +7,7 @@ Show template: $ runts -t|--template [--output script.ts] Show scriptions: -$ runts -l|--list [filter] +$ runts -l|--list [filter] [--update-listed-scripts] Install script: $ runts -i|--install