summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.rs7
-rw-r--r--src/main.rs9
2 files changed, 14 insertions, 2 deletions
diff --git a/src/channels.rs b/src/channels.rs
index 0b8acd6..b89169f 100644
--- a/src/channels.rs
+++ b/src/channels.rs
@@ -1,4 +1,5 @@
use serde::Deserialize;
+use std::fmt;
#[derive(Deserialize, Debug)]
pub struct Channel {
@@ -8,6 +9,12 @@ pub struct Channel {
pub image: String,
}
+impl fmt::Display for Channel {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}: {}", self.title, self.description)
+ }
+}
+
#[derive(Deserialize, Debug)]
pub struct Channels {
pub channels: Vec<Channel>,
diff --git a/src/main.rs b/src/main.rs
index fa1f37f..76294b9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,16 @@
+use inquire::{InquireError, Select};
use spinners::{Spinner, Spinners};
+use crate::channels::Channel;
+
mod channels;
fn main() {
let mut sp = Spinner::new(Spinners::Dots, "Loading SomaFM channels...".into());
let channels = channels::get_channels();
sp.stop();
- let groove_salad = channels.iter().find(|c| c.id == "groovesalad").unwrap();
- println!("\n{:?}", groove_salad);
+
+ let ans: Result<Channel, InquireError> = Select::new("Select a channel", channels).prompt();
+
+ println!("\n{:?}", ans);
}