Skip to content

Commit

Permalink
Add version flag (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Aug 22, 2021
1 parent 9dd0cde commit 8225c0c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions 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 bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tinysearch"
authors = ["Matthias Endler <matthias-endler@gmx.net>"]
version = "0.6.0"
version = "0.6.1"
edition = "2018"
description = "A tiny search engine for static websites"
license = "Apache-2.0/MIT"
Expand Down
15 changes: 13 additions & 2 deletions bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ static DEMO_HTML: &str = include_str!("../assets/demo.html");
#[derive(FromArgs)]
/// A tiny, static search engine for static websites
struct Opt {
/// show version and exit
#[argh(switch)]
version: bool,

/// index JSON file to process
#[argh(positional)]
index: PathBuf,
index: Option<PathBuf>,

/// output path for WASM module (local directory by default)
#[argh(option, short = 'p', long = "path")]
Expand Down Expand Up @@ -61,12 +65,19 @@ fn main() -> Result<(), Error> {
FILES.set_passthrough(env::var_os("PASSTHROUGH").is_some());

let opt: Opt = argh::from_env();

if opt.version {
println!("tinysearch {}", env!("CARGO_PKG_VERSION"));
std::process::exit(0);
}

let out_path = opt
.out_path
.unwrap_or_else(|| PathBuf::from("."))
.canonicalize()?;

let posts: Posts = index::read(fs::read_to_string(opt.index)?)?;
let index = opt.index.context("No index file specified")?;
let posts: Posts = index::read(fs::read_to_string(index)?)?;
trace!("Generating storage from posts: {:#?}", posts);
storage::write(posts)?;

Expand Down
4 changes: 2 additions & 2 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tinysearch-engine"
authors = ["Matthias Endler <matthias-endler@gmx.net>"]
version = "0.6.0"
version = "0.6.1"
edition = "2018"
description = "A tiny search engine for static websites"
license = "Apache-2.0/MIT"
Expand All @@ -17,7 +17,7 @@ once_cell = "1.8.0"

[dependencies.tinysearch-shared]
path = "../shared"
version = "0.6.0"
version = "0.6.1"

[dependencies.xorf]
version = "0.7.2"
Expand Down
2 changes: 1 addition & 1 deletion shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tinysearch-shared"
version = "0.6.0"
version = "0.6.1"
authors = ["Matthias Endler <matthias-endler@gmx.net>"]
edition = "2018"
description = "Shared libraries for tinysearch - a tiny search engine for static websites"
Expand Down

0 comments on commit 8225c0c

Please sign in to comment.