From 54278f55062e3fef2713b23182155e6ae72873e9 Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Sun, 25 Feb 2024 14:41:28 -0800 Subject: [PATCH] crude multiple input --- src/main.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index b6f1fd6..0ce855f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,28 +6,33 @@ use crate::raw_data::RawJobStats; use std::process::{Command, Stdio}; -fn get_job_stats(lodestone_id: usize) -> anyhow::Result> { - let output = Command::new("lodestone-fetcher") - .arg(lodestone_id.to_string()) - .stdout(Stdio::piped()) - .output() - .expect("Failed to execute lodestone-fetcher"); +fn get_job_stats(lodestone_ids: &[usize]) -> anyhow::Result>> { + let mut player_stats = Vec::new(); + for id in lodestone_ids { + let output = Command::new("lodestone-fetcher") + .arg(id.to_string()) + .stdout(Stdio::piped()) + .output() + .expect("Failed to execute lodestone-fetcher"); - let raw: Vec = serde_json::from_reader(&output.stdout[..])?; + let raw: Vec = serde_json::from_reader(&output.stdout[..])?; - Ok(raw.into_iter().map(|r| r.into()).collect()) + player_stats.push(Ok(raw.into_iter().map(|r| r.into()).collect())); + } + + player_stats.into_iter().collect() } fn main() -> anyhow::Result<()> { let id = 29932586; // Binglesworth - let stats = get_job_stats(id)?; - display_stats(id, &stats); + let stats = get_job_stats(std::slice::from_ref(&id))?; + display_stats(id, &stats[0]); println!(); let id = 44540671; // Dialus - let stats = get_job_stats(id)?; - display_stats(id, &stats); + let stats = get_job_stats(std::slice::from_ref(&id))?; + display_stats(id, &stats[0]); Ok(()) }