Skip to content

Commit

Permalink
Converted csv output to have quotes for name field
Browse files Browse the repository at this point in the history
  • Loading branch information
berdandy committed Mar 30, 2024
1 parent 19394a6 commit 0af7ef1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gw2search"
version = "0.8.0"
version = "0.8.1"
description = "Searches in the gw2 api. Supports items, skills and traits."
edition = "2021"
authors = ["Andy Berdan <[email protected]>"]
Expand Down
17 changes: 8 additions & 9 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Skill {
impl ResultRender for Skill {
fn pretty(&self) -> String { format!("{}: {}", self.id, self.name) }
fn id_only(&self) -> String { format!("{}", self.id) }
fn csv(&self) -> String { format!("{},{}", self.id, self.name) }
fn csv(&self) -> String { format!("{},\"{}\"", self.id, self.name) }
}

pub fn result_render(result: &impl ResultRender) -> String {
Expand Down Expand Up @@ -76,13 +76,12 @@ impl From<ApiSkill> for Skill {
pub struct Trait {
pub id: u32,
pub name: String,
// TODO: the rest?
}

impl ResultRender for Trait {
fn pretty(&self) -> String { format!("{}: {}", self.id, self.name) }
fn id_only(&self) -> String { format!("{}", self.id) }
fn csv(&self) -> String { format!("{},{}", self.id, self.name) }
fn csv(&self) -> String { format!("{},\"{}\"", self.id, self.name) }
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -137,7 +136,7 @@ pub struct Item {
impl ResultRender for Item {
fn pretty(&self) -> String { format!("{}: {}", self.id, self.name) }
fn id_only(&self) -> String { format!("{}", self.id) }
fn csv(&self) -> String { format!("{},{}", self.id, self.name) }
fn csv(&self) -> String { format!("{},\"{}\"", self.id, self.name) }
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -471,7 +470,7 @@ pub struct Spec {
impl ResultRender for Spec {
fn pretty(&self) -> String { format!("{}: {}", self.id, self.name) }
fn id_only(&self) -> String { format!("{}", self.id) }
fn csv(&self) -> String { format!("{},{}", self.id, self.name) }
fn csv(&self) -> String { format!("{},\"{}\"", self.id, self.name) }
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -516,7 +515,7 @@ pub struct Profession {
impl ResultRender for Profession {
fn pretty(&self) -> String { format!("{}: {}", self.id, self.name) }
fn id_only(&self) -> String { format!("{}", self.id) }
fn csv(&self) -> String { format!("{},{}", self.id, self.name) }
fn csv(&self) -> String { format!("{},\"{}\"", self.id, self.name) }
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -563,7 +562,7 @@ pub struct Pet {
impl ResultRender for Pet {
fn pretty(&self) -> String { format!("{}: {}", self.id, self.name) }
fn id_only(&self) -> String { format!("{}", self.id) }
fn csv(&self) -> String { format!("{},{}", self.id, self.name) }
fn csv(&self) -> String { format!("{},\"{}\"", self.id, self.name) }
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -610,7 +609,7 @@ pub struct Legend {
impl ResultRender for Legend {
fn pretty(&self) -> String { format!("{}: {}", self.id, self.name) }
fn id_only(&self) -> String { format!("{}", self.id) }
fn csv(&self) -> String { format!("{},{}", self.id, self.name) }
fn csv(&self) -> String { format!("{},\"{}\"", self.id, self.name) }
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -643,4 +642,4 @@ impl From<ApiLegend> for Legend {
name: spec.0.name,
}
}
}
}
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ pub fn main() -> iced::Result {
_ => SearchMode::Skip,
};

println!("MODE: {}", mode);

if mode != SearchMode::Skip {
let term = match &CONFIG.search_term {
Some(term) => term.clone(),
Expand Down

0 comments on commit 0af7ef1

Please sign in to comment.