this repo has no description
0
fork

Configure Feed

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

add `raw` option to disable status processing

+40 -22
+7 -2
src/main.rs
··· 172 172 173 173 #[derive(Subcommand, Debug)] 174 174 enum StatusCommands { 175 + /// Display user playing status 175 176 Show { 176 177 /// Handle or DID to query 177 178 #[arg(long)] 178 179 handle: Option<String>, 180 + 181 + /// Display raw status without processing 182 + #[arg(long, action)] 183 + raw: bool, 179 184 }, 180 185 } 181 186 ··· 357 362 } 358 363 }, 359 364 Commands::Status { command } => match command { 360 - StatusCommands::Show { handle } => { 365 + StatusCommands::Show { handle, raw } => { 361 366 let ident = match handle { 362 367 Some(s) => s, 363 368 None => { ··· 369 374 370 375 let status_man = StatusManager::new(&ident); 371 376 let status = status_man.get_status().await?; 372 - status_man.display_status(&status); 377 + status_man.display_status(&status, raw); 373 378 } 374 379 }, 375 380 }
+33 -20
src/status.rs
··· 117 117 }) 118 118 } 119 119 120 - pub fn display_status(&self, status: &TrackStatus) { 120 + pub fn display_status(&self, status: &TrackStatus, raw: bool) { 121 121 // if both track name and artists are blank, probably nothing's playing 122 122 if status.track_name.is_empty() && status.artists.is_empty() { 123 123 println!("{}", "nothing playing right now".dimmed()); ··· 145 145 } 146 146 147 147 if let Some(played_time) = &status.played_time { 148 - println!( 149 - "{} {}", 150 - "played:".dimmed(), 151 - played_time.format("%Y-%m-%d %H:%M:%S %:z").yellow() 152 - ); 148 + if raw { 149 + println!( 150 + "{} {}", 151 + "played:".dimmed(), 152 + played_time.format("%Y-%m-%d %H:%M:%S %:z").yellow() 153 + ); 154 + } else { 155 + let local_dt = played_time.with_timezone(&chrono::Local); 156 + println!( 157 + "{} {}", 158 + "played:".dimmed(), 159 + local_dt.format("%Y-%m-%d %H:%M:%S").yellow() 160 + ); 161 + } 153 162 } 154 163 155 164 if let Some(duration) = status.duration { 156 - let hours = duration / 3600; 157 - let minutes = (duration - (hours * 3600)) / 60; 158 - let seconds = duration - (minutes * 60); 165 + if raw { 166 + println!("{} {}", "duration:".dimmed(), duration.green()); 167 + } else { 168 + let hours = duration / 3600; 169 + let minutes = (duration - (hours * 3600)) / 60; 170 + let seconds = duration - (minutes * 60); 159 171 160 - let mut duration_str = "".to_string(); 161 - if hours > 0 { 162 - duration_str = format!("{:02}:", hours); 163 - } 164 - if minutes > 0 || hours > 0 { 165 - duration_str = format!("{}{:02}:", duration_str, minutes); 166 - } 167 - if seconds > 0 || minutes > 0 || hours > 0 { 168 - duration_str = format!("{}{:02}", duration_str, seconds); 169 - } 172 + let mut duration_str = "".to_string(); 173 + if hours > 0 { 174 + duration_str = format!("{:02}:", hours); 175 + } 176 + if minutes > 0 || hours > 0 { 177 + duration_str = format!("{}{:02}:", duration_str, minutes); 178 + } 179 + if seconds > 0 || minutes > 0 || hours > 0 { 180 + duration_str = format!("{}{:02}", duration_str, seconds); 181 + } 170 182 171 - println!("{} {}", "duration:".dimmed(), duration_str.green()); 183 + println!("{} {}", "duration:".dimmed(), duration_str.green()); 184 + } 172 185 } 173 186 } 174 187 }