codeberg_cli/actions/auth/
logout.rs1use crate::actions::GeneralArgs;
2use crate::paths::token_path;
3use crate::render::ui::confirm_with_prompt;
4use crate::types::context::BergContext;
5
6use clap::Parser;
7
8#[derive(Parser, Debug)]
10pub struct LogoutArgs {
11 #[arg(short, long)]
13 pub skip_confirmation: bool,
14}
15
16impl LogoutArgs {
17 pub async fn run(self, general_args: GeneralArgs) -> anyhow::Result<()> {
18 let _ = general_args;
19 let ctx = BergContext::new(self, general_args).await?;
20 if !ctx.args.skip_confirmation
21 && !confirm_with_prompt(
22 "Logging out deletes your current token. Do you want to proceed?",
23 )?
24 {
25 return Ok(());
26 }
27
28 let token_path = token_path()?;
29
30 std::fs::remove_file(token_path)?;
31
32 Ok(())
33 }
34}