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
···
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(())
···
- `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`:
+7 -1
crates/tangled-cli/src/commands/auth.rs
···
.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);