diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d7b27..5ec0ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 0.1.2 + +- Add `--version` flag to CLI to print version + ## 0.1.1 - Fix redundant newlines being inserted to generated `SUMMARY.md` diff --git a/Cargo.lock b/Cargo.lock index cd00ab4..6eb061b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -878,7 +878,7 @@ dependencies = [ [[package]] name = "mdbook-autosummary" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 0a39462..cedb230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mdbook-autosummary" -version = "0.1.1" +version = "0.1.2" edition = "2021" authors = ["hypergonial"] rust-version = "1.70" diff --git a/src/main.rs b/src/main.rs index d67ab4c..0addefc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,8 @@ use mdbook_autosummary::AutoSummary; mod logger; +const VERSION: &str = env!("CARGO_PKG_VERSION"); + pub fn make_app() -> Command { Command::new("mdbook-autosummary") .about("A mdbook preprocessor which generates a SUMMARY.md for your book based on the folder structure") @@ -19,6 +21,10 @@ pub fn make_app() -> Command { .arg(Arg::new("renderer").required(true)) .about("Check whether a renderer is supported by this preprocessor"), ) + .subcommand( + Command::new("version").long_flag("version") + .about("Print the version of this preprocessor"), + ) } fn main() { @@ -30,6 +36,9 @@ fn main() { if let Some(sub_args) = matches.subcommand_matches("supports") { handle_supports(&preprocessor, sub_args); + } else if matches.subcommand_matches("version").is_some() { + println!("mdbook-autosummary v{}", VERSION); + process::exit(0); } else if let Err(e) = handle_preprocessing(&preprocessor) { error!("{}", e); process::exit(1);