Skip to content

Commit

Permalink
book: add command
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Oct 9, 2024
1 parent bb52cfb commit 3a49e27
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 3 deletions.
153 changes: 151 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tracing = { workspace = true }
tracing-subscriber = { version = "0.3.18", features = ["json"] }
vfs = { workspace = true }
walkdir = { workspace = true }
webbrowser = "1.0.2"
whoami = "1.5.2"
zip = { workspace = true }

Expand Down
19 changes: 19 additions & 0 deletions bin/src/commands/book.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use clap::{ArgMatches, Command};

use crate::{report::Report, Error};

#[must_use]
pub fn cli() -> Command {
Command::new("book").about("Open The HEMTT book")
}

/// Execute the utils command
///
/// # Errors
/// [`Error`] depending on the modules
pub fn execute(_: &ArgMatches) -> Result<Report, Error> {
if let Err(e) = webbrowser::open("https://brettmayson.github.io/HEMTT/") {
eprintln!("Failed to open the HEMTT book: {e}");
}
Ok(Report::new())
}
1 change: 1 addition & 0 deletions bin/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod book;
pub mod build;
pub mod check;
pub mod dev;
Expand Down
4 changes: 3 additions & 1 deletion bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn cli() -> Command {
.version(env!("HEMTT_VERSION"))
.subcommand_required(false)
.arg_required_else_help(true)
.subcommand(commands::book::cli())
.subcommand(commands::new::cli())
.subcommand(commands::check::cli())
.subcommand(commands::dev::cli())
Expand Down Expand Up @@ -133,6 +134,7 @@ pub fn execute(matches: &ArgMatches) -> Result<(), Error> {
}
}
let report = match matches.subcommand() {
Some(("book", matches)) => commands::book::execute(matches).map(Some),
Some(("new", matches)) => commands::new::execute(matches).map(Some),
Some(("dev", matches)) => commands::dev::execute(matches, &[]).map(Some),
Some(("check", _matches)) => commands::check::execute().map(Some),
Expand Down Expand Up @@ -166,7 +168,7 @@ pub fn execute(matches: &ArgMatches) -> Result<(), Error> {
report.write_to_stdout();
if !matches
.subcommand_name()
.is_some_and(|s| s == "new" || s == "utils")
.is_some_and(|s| s == "new" || s == "utils" || s == "wiki" || s == "book")
{
report.write_ci_annotations()?;
}
Expand Down

0 comments on commit 3a49e27

Please sign in to comment.