Browse and listen to thousands of radio stations across the globe right from your terminal ๐ŸŒŽ ๐Ÿ“ป ๐ŸŽตโœจ
radio rust tokio web-radio command-line-tool tui

main: cli: play: --display-mode

Changed files
+18 -6
src
+9 -2
src/main.rs
··· 1 1 use anyhow::Error; 2 + use app::CurrentDisplayMode; 2 3 use clap::{arg, Command}; 3 4 4 5 mod app; ··· 46 47 Command::new("play") 47 48 .about("Play a radio station") 48 49 .arg(arg!(<station> "The station to play")) 49 - .arg(arg!(--volume "Set the initial volume (as a percent)").default_value("100")), 50 + .arg(arg!(--volume "Set the initial volume (as a percent)").default_value("100")) 51 + .arg(clap::Arg::new("display-mode").long("display-mode").help("Set the display mode to start with").default_value("Spectroscope")), 50 52 ) 51 53 .subcommand( 52 54 Command::new("browse") ··· 92 94 let station = args.value_of("station").unwrap(); 93 95 let provider = matches.value_of("provider").unwrap(); 94 96 let volume = args.value_of("volume").unwrap().parse::<f32>().unwrap(); 95 - play::exec(station, provider, volume).await?; 97 + let display_mode = args 98 + .value_of("display-mode") 99 + .unwrap() 100 + .parse::<CurrentDisplayMode>() 101 + .unwrap(); 102 + play::exec(station, provider, volume, display_mode).await?; 96 103 } 97 104 Some(("browse", args)) => { 98 105 let category = args.value_of("category");
+9 -4
src/play.rs
··· 4 4 use hyper::header::HeaderValue; 5 5 6 6 use crate::{ 7 - app::{App, State, Volume}, 7 + app::{App, CurrentDisplayMode, State, Volume}, 8 8 cfg::{SourceOptions, UiOptions}, 9 9 decoder::Mp3Decoder, 10 10 provider::{radiobrowser::Radiobrowser, tunein::Tunein, Provider}, 11 11 tui, 12 12 }; 13 13 14 - pub async fn exec(name_or_id: &str, provider: &str, default_volume: f32) -> Result<(), Error> { 14 + pub async fn exec( 15 + name_or_id: &str, 16 + provider: &str, 17 + volume: f32, 18 + display_mode: CurrentDisplayMode, 19 + ) -> Result<(), Error> { 15 20 let _provider = provider; 16 21 let provider: Box<dyn Provider> = match provider { 17 22 "tunein" => Box::new(Tunein::new()), ··· 52 57 tune: None, 53 58 }; 54 59 55 - let mut app = App::new(&ui, &opts, frame_rx); 60 + let mut app = App::new(&ui, &opts, frame_rx, display_mode); 56 61 let station_name = station.name.clone(); 57 62 58 63 thread::spawn(move || { ··· 61 66 let response = client.get(stream_url).send().unwrap(); 62 67 63 68 let headers = response.headers(); 64 - let volume = Volume::new(default_volume, false); 69 + let volume = Volume::new(volume, false); 65 70 66 71 cmd_tx 67 72 .send(State {