Skip to content

Commit

Permalink
Add --version
Browse files Browse the repository at this point in the history
  • Loading branch information
hypergonial committed Sep 26, 2023
1 parent 1f3bef5 commit ba0db26
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mdbook-autosummary"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["hypergonial"]
rust-version = "1.70"
Expand Down
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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() {
Expand All @@ -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);
Expand Down

0 comments on commit ba0db26

Please sign in to comment.