Give warning about pds flag on failed login #2

merged
opened by t1c.dev targeting main from t1c.dev/tangled-cli: pds-warn

If tangled-cli auth login fails, the warning If you're on your own PDS, make sure to pass the --pds flag is displayed

Changed files
+15 -3
crates
tangled-cli
src
commands
+8 -2
AGENTS.md
··· 245 245 let password: String = match args.password.take() { Some(p) => p, None => Password::new().with_prompt("Password").interact()? }; 246 246 let pds = args.pds.unwrap_or_else(|| "https://bsky.social".to_string()); 247 247 let client = tangled_api::TangledClient::new(&pds); 248 - let session = client.login_with_password(&handle, &password, &pds).await?; 248 + let mut session = match client.login_with_password(&handle, &password, &pds).await { 249 + Ok(sess) => sess, 250 + Err(e) => { 251 + println!("\x1b[93mIf you're on your own PDS, make sure to pass the --pds flag\x1b[0m"); 252 + return Err(e); 253 + } 254 + }; 249 255 SessionManager::default().save(&session)?; 250 256 println!("Logged in as '{}' ({})", session.handle, session.did); 251 257 Ok(()) ··· 314 320 315 321 - `tangled auth login`: 316 322 - Prompts or uses flags; successful call saves session and prints `Logged in as ...`. 317 - - On failure, shows HTTP status and short message. 323 + - On failure, shows HTTP status and error message, plus helpful hint about --pds flag for users on their own PDS. 318 324 - `tangled auth status`: 319 325 - Shows handle + did if session exists; otherwise says not logged in. 320 326 - `tangled auth logout`:
+7 -1
crates/tangled-cli/src/commands/auth.rs
··· 26 26 .unwrap_or_else(|| "https://bsky.social".to_string()); 27 27 28 28 let client = tangled_api::TangledClient::new(&pds); 29 - let mut session = client.login_with_password(&handle, &password, &pds).await?; 29 + let mut session = match client.login_with_password(&handle, &password, &pds).await { 30 + Ok(sess) => sess, 31 + Err(e) => { 32 + println!("\x1b[93mIf you're on your own PDS, make sure to pass the --pds flag\x1b[0m"); 33 + return Err(e); 34 + } 35 + }; 30 36 session.pds = Some(pds.clone()); 31 37 SessionManager::default().save(&session)?; 32 38 println!("Logged in as '{}' ({})", session.handle, session.did);