this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

improve output for `auth whoami` command

+47 -5
+47 -4
src/main.rs
··· 1 + use jacquard::{prelude::IdentityResolver, types::did::Did}; 1 2 use owo_colors::OwoColorize; 2 3 use serde::{Deserialize, Serialize}; 3 4 use std::path::PathBuf; 4 5 5 6 use crate::{ 6 - auth::{Authenticator, GenericSession}, 7 + auth::{AuthMethod, Authenticator, GenericSession}, 7 8 error::OnyxError, 8 9 parser::{ParsedArtist, ParsedTrack}, 9 10 scrobble::Scrobbler, ··· 200 201 } 201 202 AuthCommands::Whoami => { 202 203 let auth = get_auth()?; 203 - let session = auth.get_session_info()?; 204 - println!("logged in as {}", session.did); 204 + let session_info = auth.get_session_info()?; 205 + let session = auth.restore().await; 206 + 207 + let method_str = if session_info.auth == AuthMethod::OAuth { 208 + "oauth" 209 + } else { 210 + "app password" 211 + }; 212 + 213 + if let Ok(session) = session { 214 + println!( 215 + "{} {} {} {}", 216 + "status:".dimmed(), 217 + "logged in".green(), 218 + "via".dimmed(), 219 + method_str.blue() 220 + ); 221 + 222 + let did_doc = session.resolve_did_doc(&Did::new(&session_info.did)?).await; 223 + if let Ok(did_doc) = did_doc 224 + && let Ok(doc) = did_doc.parse() 225 + { 226 + print!("{}", "handles: ".dimmed()); 227 + for handle in doc.handles() { 228 + print!("{} ", handle.magenta()); 229 + } 230 + println!(); 231 + } 232 + } else { 233 + println!( 234 + "{} {} {} {}", 235 + "status:".dimmed(), 236 + "logged out".red().bold(), 237 + "via".dimmed(), 238 + method_str.blue() 239 + ); 240 + } 241 + 242 + println!("{}", format!("did: {}", session_info.did).dimmed()); 205 243 } 206 244 }, 207 245 Commands::Scrobble { command } => match command { ··· 254 292 let session = get_session().await?; 255 293 let scrobbler = Scrobbler::new("onyx", &version, session); 256 294 scrobbler.scrobble_track(track).await?; 295 + 296 + println!("{}: track submitted", "success".green().bold()); 257 297 } 258 298 ScrobbleCommands::Logfile { 259 299 log, ··· 267 307 268 308 if delete { 269 309 std::fs::remove_file(&log)?; 270 - println!("deleted log file {}", log.to_str().unwrap()); 310 + println!( 311 + "{}", 312 + format!("deleted log: {}", log.to_str().unwrap()).dimmed() 313 + ); 271 314 } 272 315 } 273 316 },
-1
src/scrobble.rs
··· 6 6 use jacquard_api::fm_teal::alpha::feed::{Artist, play::Play}; 7 7 use owo_colors::OwoColorize; 8 8 9 - use crate::print_error; 10 9 use crate::{ 11 10 LogFormat, 12 11 auth::GenericSession,