feat: v1.1.6
This commit is contained in:
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user