summaryrefslogtreecommitdiff
path: root/src/bin/jv.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-11-24 13:48:16 +0800
committer魏曹先生 <1992414357@qq.com>2025-11-24 13:48:16 +0800
commit84dfa3e964dc775aa4e47363e74709a87d768067 (patch)
tree979ff205b3dd84c9cea4c7ce5ea482ce5cb93efd /src/bin/jv.rs
parent5ebd07e52b4ebc1f59b603bbd4fe781871056755 (diff)
Add silent mode to `jv_update` command
When JV_AUTO_UPDATE is enabled, the update will now run silently without outputting any messages. This prevents unnecessary console output during automatic updates while preserving normal output when manually invoked.
Diffstat (limited to 'src/bin/jv.rs')
-rw-r--r--src/bin/jv.rs58
1 files changed, 37 insertions, 21 deletions
diff --git a/src/bin/jv.rs b/src/bin/jv.rs
index 773af96..5dea8f7 100644
--- a/src/bin/jv.rs
+++ b/src/bin/jv.rs
@@ -546,6 +546,10 @@ struct UpdateArgs {
/// Show help information
#[arg(short, long)]
help: bool,
+
+ /// Silent mode
+ #[arg(short, long)]
+ silent: bool,
}
#[derive(Parser, Debug)]
@@ -607,7 +611,11 @@ async fn main() {
// Auto update
if enable_auto_update() && check_vault_modified().await {
- jv_update(UpdateArgs { help: false }).await;
+ jv_update(UpdateArgs {
+ help: false,
+ silent: true,
+ })
+ .await;
}
let Ok(parser) = JustEnoughVcsWorkspace::try_parse() else {
@@ -1016,7 +1024,11 @@ async fn main() {
})
.await;
- jv_update(UpdateArgs { help: false }).await;
+ jv_update(UpdateArgs {
+ help: false,
+ silent: true,
+ })
+ .await;
if let Some(local_dir) = current_local_path() {
let _ = fs::remove_file(local_dir.join(CLIENT_FILE_TODOLIST)).await;
@@ -2635,7 +2647,7 @@ async fn jv_account_generate_pub_key(user_dir: UserDirectory, args: GeneratePubl
}
}
-async fn jv_update(_update_file_args: UpdateArgs) {
+async fn jv_update(update_file_args: UpdateArgs) {
let local_config = match precheck().await {
Some(config) => config,
None => return,
@@ -2648,27 +2660,31 @@ async fn jv_update(_update_file_args: UpdateArgs) {
match proc_update_to_latest_info_action(&pool, ctx, ()).await {
Err(e) => handle_err(e),
- Ok(result) => match result {
- UpdateToLatestInfoResult::Success => {
- println!("{}", md(t!("jv.result.update.success")));
- }
- UpdateToLatestInfoResult::AuthorizeFailed(e) => {
- eprintln!("{}", md(t!("jv.result.common.authroize_failed", err = e)))
- }
- UpdateToLatestInfoResult::SyncCachedSheetFail(sync_cached_sheet_fail_reason) => {
- match sync_cached_sheet_fail_reason {
- SyncCachedSheetFailReason::PathAlreadyExist(path_buf) => {
- eprintln!(
- "{}",
- md(t!(
- "jv.result.update.fail.sync_cached_sheet_fail.path_already_exist",
- path = path_buf.display()
- ))
- );
+ Ok(result) => {
+ if !update_file_args.silent {
+ match result {
+ UpdateToLatestInfoResult::Success => {
+ println!("{}", md(t!("jv.result.update.success")));
+ }
+ UpdateToLatestInfoResult::AuthorizeFailed(e) => {
+ eprintln!("{}", md(t!("jv.result.common.authroize_failed", err = e)))
}
+ UpdateToLatestInfoResult::SyncCachedSheetFail(
+ sync_cached_sheet_fail_reason,
+ ) => match sync_cached_sheet_fail_reason {
+ SyncCachedSheetFailReason::PathAlreadyExist(path_buf) => {
+ eprintln!(
+ "{}",
+ md(t!(
+ "jv.result.update.fail.sync_cached_sheet_fail.path_already_exist",
+ path = path_buf.display()
+ ))
+ );
+ }
+ },
}
}
- },
+ }
}
}