Skip to content

Commit

Permalink
allow identifier string to be searched
Browse files Browse the repository at this point in the history
  • Loading branch information
buckley-w-david committed Nov 20, 2021
1 parent 7fcda95 commit fcbe103
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The text that will be searched for is given after the selector.
- *e*: edition.
- *v*: volume.
- *n*: number.
- *i*: identifier.

### State selectors

Expand Down
4 changes: 4 additions & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ pub struct BookQuery {
pub edition: Option<Regex>,
pub volume: Option<Regex>,
pub number: Option<Regex>,
pub identifier: Option<Regex>,
pub reading: Option<bool>,
pub new: Option<bool>,
pub finished: Option<bool>,
Expand Down Expand Up @@ -492,6 +493,7 @@ impl BookQuery {
Some('e') => { buf.reverse(); query.edition = make_query(&buf.join(" ")); buf.clear(); },
Some('v') => { buf.reverse(); query.volume = make_query(&buf.join(" ")); buf.clear(); },
Some('n') => { buf.reverse(); query.number = make_query(&buf.join(" ")); buf.clear(); },
Some('i') => { buf.reverse(); query.identifier = make_query(&buf.join(" ")); buf.clear(); },
Some('R') => query.reading = Some(!invert),
Some('N') => query.new = Some(!invert),
Some('F') => query.finished = Some(!invert),
Expand Down Expand Up @@ -529,6 +531,7 @@ impl BookQuery {
query.edition.is_none() &&
query.volume.is_none() &&
query.number.is_none() &&
query.identifier.is_none() &&
query.reading.is_none() &&
query.new.is_none() &&
query.finished.is_none() &&
Expand Down Expand Up @@ -560,6 +563,7 @@ impl BookQuery {
self.edition.as_ref().map(|re| re.is_match(&info.edition)) != Some(false) &&
self.volume.as_ref().map(|re| re.is_match(&info.volume)) != Some(false) &&
self.number.as_ref().map(|re| re.is_match(&info.number)) != Some(false) &&
self.identifier.as_ref().map(|re| re.is_match(&info.identifier)) != Some(false) &&
self.reading.as_ref().map(|eq| info.simple_status().eq(&SimpleStatus::Reading) == *eq) != Some(false) &&
self.new.as_ref().map(|eq| info.simple_status().eq(&SimpleStatus::New) == *eq) != Some(false) &&
self.finished.as_ref().map(|eq| info.simple_status().eq(&SimpleStatus::Finished) == *eq) != Some(false) &&
Expand Down

0 comments on commit fcbe103

Please sign in to comment.