Skip to content

Commit

Permalink
[CLI] Close handles with symbol instead of newline.
Browse files Browse the repository at this point in the history
Otherwise they stop on whatever part of the loading
animation they happen to be.
  • Loading branch information
AureliaDolo committed Jan 14, 2025
1 parent dbf147d commit ad8f345
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
27 changes: 13 additions & 14 deletions cli/src/commands/invite/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -100,7 +100,7 @@ async fn step1_user(ctx: UserClaimInitialCtx) -> anyhow::Result<UserClaimInProgr

let ctx = ctx.do_wait_peer().await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand All @@ -116,7 +116,7 @@ async fn step1_device(ctx: DeviceClaimInitialCtx) -> anyhow::Result<DeviceClaimI

let ctx = ctx.do_wait_peer().await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand Down Expand Up @@ -164,7 +164,7 @@ async fn step3_user(ctx: UserClaimInProgress2Ctx) -> anyhow::Result<UserClaimInP

let ctx = ctx.do_wait_peer_trust().await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand All @@ -180,7 +180,7 @@ async fn step3_device(ctx: DeviceClaimInProgress2Ctx) -> anyhow::Result<DeviceCl

let ctx = ctx.do_wait_peer_trust().await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand All @@ -195,7 +195,7 @@ async fn step4_user(ctx: UserClaimInProgress3Ctx) -> anyhow::Result<UserClaimFin

let ctx = ctx.do_claim_user(device_label, human_handle).await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand All @@ -209,7 +209,7 @@ async fn step4_device(ctx: DeviceClaimInProgress3Ctx) -> anyhow::Result<DeviceCl

let ctx = ctx.do_claim_device(device_label).await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand Down Expand Up @@ -237,30 +237,29 @@ async fn save_user(ctx: UserClaimFinalizeCtx, save_mode: SaveMode) -> 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(())
}

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(())
}
14 changes: 7 additions & 7 deletions cli/src/commands/invite/greet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -86,7 +86,7 @@ async fn step1_user(ctx: UserGreetInitialCtx) -> anyhow::Result<UserGreetInProgr

let ctx = ctx.do_wait_peer().await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand All @@ -97,7 +97,7 @@ async fn step1_device(ctx: DeviceGreetInitialCtx) -> anyhow::Result<DeviceGreetI

let ctx = ctx.do_wait_peer().await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand All @@ -113,7 +113,7 @@ async fn step2_user(ctx: UserGreetInProgress1Ctx) -> anyhow::Result<UserGreetInP

let ctx = ctx.do_wait_peer_trust().await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand All @@ -129,7 +129,7 @@ async fn step2_device(ctx: DeviceGreetInProgress1Ctx) -> anyhow::Result<DeviceGr

let ctx = ctx.do_wait_peer_trust().await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(ctx)
}
Expand Down Expand Up @@ -189,7 +189,7 @@ async fn step5_user(ctx: UserGreetInProgress4Ctx) -> anyhow::Result<()> {
ctx.do_create_new_user(device_label, human_handle, profile)
.await?;

handle.stop_with_newline();
handle.stop_with_symbol(GREEN_CHECKMARK);

Ok(())
}
Expand All @@ -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(())
}
2 changes: 1 addition & 1 deletion cli/src/commands/shared_recovery/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions newsfragments/9109.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[CLI] Stop spinners with check mark.

0 comments on commit ad8f345

Please sign in to comment.