From ad8f3450987d88266de3597cf48c412f48fb57cd Mon Sep 17 00:00:00 2001 From: Aurelia Date: Mon, 13 Jan 2025 16:31:52 +0100 Subject: [PATCH] [CLI] Close handles with symbol instead of newline. Otherwise they stop on whatever part of the loading animation they happen to be. --- cli/src/commands/invite/claim.rs | 27 +++++++++++----------- cli/src/commands/invite/greet.rs | 14 +++++------ cli/src/commands/shared_recovery/create.rs | 2 +- cli/src/utils.rs | 2 +- newsfragments/9109.bugfix.rst | 1 + 5 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 newsfragments/9109.bugfix.rst diff --git a/cli/src/commands/invite/claim.rs b/cli/src/commands/invite/claim.rs index 9df838199bb..b9f542b6f1c 100644 --- a/cli/src/commands/invite/claim.rs +++ b/cli/src/commands/invite/claim.rs @@ -84,7 +84,7 @@ async fn step0( let ctx = claimer_retrieve_info(Arc::new(config.into()), addr, None).await?; - handle.stop_with_newline(); + handle.stop_with_symbol(GREEN_CHECKMARK); Ok(ctx) } @@ -100,7 +100,7 @@ async fn step1_user(ctx: UserClaimInitialCtx) -> anyhow::Result anyhow::Result anyhow::Result anyhow::Result anyhow::Result anyhow::Result anyhow::Re let key_file = ctx.get_default_key_file(); let access = get_access_strategy(key_file, save_mode)?; - println!( + let mut handle = start_spinner(format!( "Saving device at: {YELLOW}{}{RESET}", access.key_file().display() - ); + )); ctx.save_local_device(&access).await?; - println!("Saved"); + handle.stop_with_symbol(GREEN_CHECKMARK); Ok(()) } @@ -252,15 +252,14 @@ async fn save_user(ctx: UserClaimFinalizeCtx, save_mode: SaveMode) -> anyhow::Re async fn save_device(ctx: DeviceClaimFinalizeCtx, save_mode: SaveMode) -> anyhow::Result<()> { let key_file = ctx.get_default_key_file(); let access = get_access_strategy(key_file, save_mode)?; - - println!( + let mut handle = start_spinner(format!( "Saving device at: {YELLOW}{}{RESET}", access.key_file().display() - ); + )); ctx.save_local_device(&access).await?; - println!("Saved"); + handle.stop_with_symbol(GREEN_CHECKMARK); Ok(()) } diff --git a/cli/src/commands/invite/greet.rs b/cli/src/commands/invite/greet.rs index 42621f109d8..15eb661f1d5 100644 --- a/cli/src/commands/invite/greet.rs +++ b/cli/src/commands/invite/greet.rs @@ -75,7 +75,7 @@ async fn step0( None => return Err(anyhow::anyhow!("Invitation not found")), }; - handle.stop_with_newline(); + handle.stop_with_symbol(GREEN_CHECKMARK); Ok(invitation) } @@ -86,7 +86,7 @@ async fn step1_user(ctx: UserGreetInitialCtx) -> anyhow::Result anyhow::Result anyhow::Result anyhow::Result anyhow::Result<()> { ctx.do_create_new_user(device_label, human_handle, profile) .await?; - handle.stop_with_newline(); + handle.stop_with_symbol(GREEN_CHECKMARK); Ok(()) } @@ -203,7 +203,7 @@ async fn step5_device(ctx: DeviceGreetInProgress4Ctx) -> anyhow::Result<()> { ctx.do_create_new_device(device_label).await?; - handle.stop_with_newline(); + handle.stop_with_symbol(GREEN_CHECKMARK); Ok(()) } diff --git a/cli/src/commands/shared_recovery/create.rs b/cli/src/commands/shared_recovery/create.rs index 6b62ae3f329..5a9950b54a2 100644 --- a/cli/src/commands/shared_recovery/create.rs +++ b/cli/src/commands/shared_recovery/create.rs @@ -84,7 +84,7 @@ pub async fn create_shared_recovery(args: Args, client: &StartedClient) -> anyho .collect() }; // we must stop the handle here to avoid messing up with the threshold choice - handle.stop_with_newline(); + handle.stop_with_symbol("..."); // not green check mark because it's not finished let threshold = if let Some(t) = threshold { t } else { diff --git a/cli/src/utils.rs b/cli/src/utils.rs index ce05684dc64..c20e930523e 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -322,7 +322,7 @@ pub async fn start_client_with_config( start_spinner("Device already used by another process, waiting...".into()); let device_in_use_guard = lock_device_for_use(&config.config_dir, device.device_id).await?; - handle.stop_with_newline(); + handle.stop_with_message(format!("{GREEN_CHECKMARK} Device accessed")); device_in_use_guard } Err(TryLockDeviceForUseError::Internal(err)) => return Err(err), diff --git a/newsfragments/9109.bugfix.rst b/newsfragments/9109.bugfix.rst new file mode 100644 index 00000000000..c94e747e26a --- /dev/null +++ b/newsfragments/9109.bugfix.rst @@ -0,0 +1 @@ +[CLI] Stop spinners with check mark.