From 15a8c1c22142b2c941ab2589a11131dc373e4f0b Mon Sep 17 00:00:00 2001 From: KeksNino Date: Fri, 23 Jan 2026 23:53:45 +0100 Subject: [PATCH] show post author in FuzzySelect list --- src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index aaeb52e..7bab8dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use futures::FutureExt; use select::document::Document; use select::predicate::Name; use serde::Deserialize; -use serde_json::{json, Value}; +use serde_json::Value; use std::io; use std::process::Command; use std::sync::Arc; @@ -13,7 +13,7 @@ use tokio::{spawn, sync::Semaphore}; #[derive(Debug, Deserialize)] struct Software { - //author: String, + author: String, title: String, url: String, } @@ -49,10 +49,17 @@ async fn main() -> Result<(), Box> { serde_json::from_value(data.clone()).expect("Failed to parse JSON into Software"); let titles: Vec<&str> = items.iter().map(|s| s.title.as_str()).collect(); + let author: Vec<&str> = items.iter().map(|s| s.author.as_str()).collect(); + + let items2: Vec = titles + .iter() + .zip(author.iter()) + .map(|(t, a)| format!("{:<80} by {}", t, a)) + .collect(); let selection = FuzzySelect::new() .with_prompt("Pick your software") - .items(&titles) + .items(&items2) .interact() .unwrap();