feat: v1.1.6
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1221,7 +1221,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "runrs"
|
||||
version = "1.1.5"
|
||||
version = "1.1.6"
|
||||
dependencies = [
|
||||
"argh",
|
||||
"reqwest",
|
||||
|
||||
@@ -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"
|
||||
|
||||
23
src/list.rs
23
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<String>, filter: Option<&String>) {
|
||||
pub fn list_scripts(
|
||||
script_repo: &Option<String>,
|
||||
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<String>, 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<String>, 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
src/main.rs
13
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<bool>,
|
||||
/// script repo
|
||||
#[argh(option, short = 'R')]
|
||||
script_repo: Option<String>,
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 <script.dart>
|
||||
|
||||
@@ -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 <script.go>
|
||||
|
||||
@@ -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 <script.rs>
|
||||
|
||||
@@ -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 <script.ts>
|
||||
|
||||
Reference in New Issue
Block a user