Improved Null in db
Fixed the rofi error window from instantly being removed with a double click - there's probably a better way like using some IGNORE_FIRST_CLICK_FOR_10ms or something
This commit is contained in:
@@ -6,4 +6,7 @@ SELECTION=$(rofi -dmenu <<< "$CARDS")
|
||||
|
||||
CARD_OUTPUT=$(/home/arthurr/code/mini_projects/scryfall_deser/target/debug/scryfall_deser --exact $SELECTION)
|
||||
|
||||
# If you double check the first rofi selection it seems to prevent the error window from popping up
|
||||
sleep 0.05
|
||||
|
||||
rofi -e "$CARD_OUTPUT"
|
||||
|
||||
@@ -54,24 +54,24 @@ pub fn update_db_with_file(file: PathBuf) -> bool {
|
||||
}
|
||||
let lowercase_name = card.name.to_lowercase();
|
||||
let power_toughness = match card.power {
|
||||
Some(p) => format!("{}/{}", p, card.toughness.unwrap()),
|
||||
None => "".to_string(),
|
||||
Some(p) => Some(format!("{}/{}", p, card.toughness.unwrap())),
|
||||
None => None,
|
||||
};
|
||||
let oracle_text = match card.oracle_text {
|
||||
Some(ot) => ot,
|
||||
None => "".to_string(),
|
||||
None => "<No Oracle Text>".to_string(),
|
||||
};
|
||||
let loyalty = match card.loyalty {
|
||||
Some(loy) => loy,
|
||||
None => "".to_string(),
|
||||
Some(loy) => Some(loy),
|
||||
None => None,
|
||||
};
|
||||
let mana_cost = match card.mana_cost {
|
||||
Some(mc) => mc,
|
||||
None => "".to_string(),
|
||||
Some(mc) => Some(mc),
|
||||
None => None,
|
||||
};
|
||||
let res = tx.execute(
|
||||
"INSERT INTO cards (name, lowercase_name, type_line, oracle_text, power_toughness, loyalty, mana_cost, scryfall_uri) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)",
|
||||
[card.name, lowercase_name, card.type_line, oracle_text, power_toughness, loyalty, mana_cost, card.scryfall_uri],
|
||||
rusqlite::params![card.name, lowercase_name, card.type_line, oracle_text, power_toughness, loyalty, mana_cost, card.scryfall_uri],
|
||||
);
|
||||
}
|
||||
tx.commit();
|
||||
@@ -86,10 +86,20 @@ impl fmt::Display for DbCard {
|
||||
Some(mc) => writeln!(f, "{}\t{}", self.name, mc)?,
|
||||
None => writeln!(f, "{}", self.name)?,
|
||||
}
|
||||
writeln!(f, "{}", self.type_line)?;
|
||||
match &self.oracle_text {
|
||||
Some(ot) => writeln!(f, "{}", ot)?,
|
||||
None => (),
|
||||
}
|
||||
match &self.power_toughness {
|
||||
Some(pt) => writeln!(f, "{}", pt)?,
|
||||
None => (),
|
||||
}
|
||||
match &self.loyalty {
|
||||
Some(l) => writeln!(f, "Starting Loyalty: {}", l)?,
|
||||
None => (),
|
||||
}
|
||||
writeln!(f, "{}", self.scryfall_uri)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user