From f31763330029fdc7e2295b443a0c637f2718ef4e Mon Sep 17 00:00:00 2001 From: Kainoa Kanter Date: Mon, 6 Oct 2025 13:48:37 -0700 Subject: [PATCH] on auth failure, give helpful warning about --pds flag --- AGENTS.md | 10 ++++++++-- crates/tangled-cli/src/commands/auth.rs | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1410e74..39eb979 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -245,7 +245,13 @@ async fn login(mut args: AuthLoginArgs) -> Result<()> { let password: String = match args.password.take() { Some(p) => p, None => Password::new().with_prompt("Password").interact()? }; let pds = args.pds.unwrap_or_else(|| "https://bsky.social".to_string()); let client = tangled_api::TangledClient::new(&pds); - let session = client.login_with_password(&handle, &password, &pds).await?; + let mut session = match client.login_with_password(&handle, &password, &pds).await { + Ok(sess) => sess, + Err(e) => { + println!("\x1b[93mIf you're on your own PDS, make sure to pass the --pds flag\x1b[0m"); + return Err(e); + } + }; SessionManager::default().save(&session)?; println!("Logged in as '{}' ({})", session.handle, session.did); Ok(()) @@ -314,7 +320,7 @@ async fn list(args: RepoListArgs) -> Result<()> { - `tangled auth login`: - Prompts or uses flags; successful call saves session and prints `Logged in as ...`. - - On failure, shows HTTP status and short message. + - On failure, shows HTTP status and error message, plus helpful hint about --pds flag for users on their own PDS. - `tangled auth status`: - Shows handle + did if session exists; otherwise says not logged in. - `tangled auth logout`: diff --git a/crates/tangled-cli/src/commands/auth.rs b/crates/tangled-cli/src/commands/auth.rs index a5973cb..7846b92 100644 --- a/crates/tangled-cli/src/commands/auth.rs +++ b/crates/tangled-cli/src/commands/auth.rs @@ -26,7 +26,13 @@ async fn login(_cli: &Cli, mut args: AuthLoginArgs) -> Result<()> { .unwrap_or_else(|| "https://bsky.social".to_string()); let client = tangled_api::TangledClient::new(&pds); - let mut session = client.login_with_password(&handle, &password, &pds).await?; + let mut session = match client.login_with_password(&handle, &password, &pds).await { + Ok(sess) => sess, + Err(e) => { + println!("\x1b[93mIf you're on your own PDS, make sure to pass the --pds flag\x1b[0m"); + return Err(e); + } + }; session.pds = Some(pds.clone()); SessionManager::default().save(&session)?; println!("Logged in as '{}' ({})", session.handle, session.did); -- 2.43.0