Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract serial API #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fzyr"
version = "0.2.0"
version = "0.3.0"
homepage = "https://github.com/jmaargh/fzyr"
authors = ["jmaargh <https://github.com/jmaargh>"]

Expand All @@ -25,16 +25,21 @@ name = "fzyr"
name = "fzyr"
path = "src/bin/main.rs"
doc = false
required-features = ["binary-build"]


[dependencies]
ndarray = "^0.11.2"
itertools = "^0.7.8"
crossbeam = "^0.4.1"
bit-vec = "^0.5.0"
clap = "^2.32.0"
console = "^0.6.1"

ndarray = "^0.15"
bit-vec = "^0.6.0"
itertools = { version = "^0.10", optional = true }
crossbeam = { version = "^0.8", optional = true }
clap = { version = "^3.1", optional = true }
console = { version = "^0.15", optional = true }

[features]
default = ["binary-build", "parallel"]
binary-build = ["clap", "console"]
parallel = ["itertools", "crossbeam"]

[profile.release]
opt-level = 3
Expand Down
34 changes: 17 additions & 17 deletions src/bin/opts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate clap;

use self::clap::{App, Arg};
use self::clap::{Command, Arg};

pub const NAME: &'static str = env!("CARGO_PKG_NAME");
pub const VERSION: &'static str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -43,65 +43,65 @@ pub fn cmd_parse() -> Options {

let long_about: String = format!("{}\n[{}]", DESCRIPTION, WEBSITE);

let matches = App::new(NAME)
let matches = Command::new(NAME)
.version(VERSION)
.about(DESCRIPTION)
.long_about(long_about.as_ref())
.arg(
Arg::with_name("query")
.short("q")
Arg::new("query")
.short('q')
.long("query")
.value_name("QUERY")
.default_value(&deflt_query)
.help("Query string to search for"),
)
.arg(
Arg::with_name("lines")
.short("l")
Arg::new("lines")
.short('l')
.long("lines")
.value_name("LINES")
.default_value(&deflt_lines)
.help("Number of output lines to display"),
)
.arg(
Arg::with_name("show-scores")
.short("s")
Arg::new("show-scores")
.short('s')
.long("show-scores")
.help("Show numerical scores for each match"),
)
.arg(
Arg::with_name("parallelism")
.short("j")
Arg::new("parallelism")
.short('j')
.long("parallelism")
.value_name("THREADS")
.default_value(&deflt_parallelism)
.help("Maximum number of worker threads to use"),
)
.arg(
Arg::with_name("prompt")
.short("p")
Arg::new("prompt")
.short('p')
.long("prompt")
.value_name("PROMPT")
.default_value(&deflt_prompt)
.help("Propmt to show when entering queries"),
)
.arg(
Arg::with_name("benchmark")
.short("b")
Arg::new("benchmark")
.short('b')
.long("benchmark")
.value_name("REPEATS")
.default_value(&deflt_benchmark)
.help("Set to a positive value to run that many repeated searches for benchmarking"),
)
.arg(
Arg::with_name("workers")
Arg::new("workers")
.long("workers")
.value_name("THREADS")
.help("Identical to \"--parallelism\""),
)
.arg(
Arg::with_name("show-matches")
.short("e")
Arg::new("show-matches")
.short('e')
.long("show-matches")
.value_name("QUERY")
.help("Identical to \"--query\""),
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ mod score;
mod search;

pub use score::{config, has_match, locate, score, LocateResult, Score, ScoreResult};
pub use search::{search_locate, search_score, LocateResults, ScoreResults};
pub use search::{search_serial, locate_serial, LocateResults, ScoreResults};

#[cfg(feature = "parallel")]
pub use search::{search_locate, search_score};
Loading