crude multiple input

This commit is contained in:
Zynh0722 2024-02-25 14:41:28 -08:00
parent 0c75859cd2
commit 54278f5506

View file

@ -6,28 +6,33 @@ use crate::raw_data::RawJobStats;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
fn get_job_stats(lodestone_id: usize) -> anyhow::Result<Vec<JobStats>> { fn get_job_stats(lodestone_ids: &[usize]) -> anyhow::Result<Vec<Vec<JobStats>>> {
let mut player_stats = Vec::new();
for id in lodestone_ids {
let output = Command::new("lodestone-fetcher") let output = Command::new("lodestone-fetcher")
.arg(lodestone_id.to_string()) .arg(id.to_string())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.output() .output()
.expect("Failed to execute lodestone-fetcher"); .expect("Failed to execute lodestone-fetcher");
let raw: Vec<RawJobStats> = serde_json::from_reader(&output.stdout[..])?; let raw: Vec<RawJobStats> = 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<()> { fn main() -> anyhow::Result<()> {
let id = 29932586; // Binglesworth let id = 29932586; // Binglesworth
let stats = get_job_stats(id)?; let stats = get_job_stats(std::slice::from_ref(&id))?;
display_stats(id, &stats); display_stats(id, &stats[0]);
println!(); println!();
let id = 44540671; // Dialus let id = 44540671; // Dialus
let stats = get_job_stats(id)?; let stats = get_job_stats(std::slice::from_ref(&id))?;
display_stats(id, &stats); display_stats(id, &stats[0]);
Ok(()) Ok(())
} }