bw/key_management/lock.rs
1use clap::Args;
2
3use crate::{
4 client_state::{BwCommand, LoggedIn},
5 render::CommandResult,
6};
7
8#[derive(Args, Clone)]
9pub struct LockArgs;
10
11impl BwCommand for LockArgs {
12 // `LoggedIn` (rather than `Unlocked`) is intentional: the legacy node CLI accepts `bw lock`
13 // when the vault is already locked, and we preserve that behavior for compatibility.
14 type Client = LoggedIn;
15
16 async fn run(self, LoggedIn { user, .. }: LoggedIn) -> CommandResult {
17 user.invalidate_session_key().await?;
18 Ok("Your vault is now locked.".into())
19 }
20}