Skip to content

Commit

Permalink
feat: switch to clap v4
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham committed Sep 17, 2023
1 parent 3dda0be commit a1ddb9a
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 11 deletions.
95 changes: 91 additions & 4 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ name = "mdbook_catppuccin"
path = "src/lib.rs"

[dependencies]
clap = { version = "3.2.25", features = ["cargo"] }
clap = { version = "4.4.3", features = ["cargo"] }
mdbook = "=0.4.22"
env_logger = "0.10.0"
log = "0.4.20"
Expand Down
14 changes: 8 additions & 6 deletions src/bin/mdbook-catppuccin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{io, process};

use clap::{crate_version, Arg, ArgMatches, Command};
use clap::{command, crate_version, Arg, ArgMatches, Command};
use mdbook::errors::Error;
use mdbook::preprocess::{CmdPreprocessor, Preprocessor};
use semver::{Version, VersionReq};
Expand All @@ -23,8 +23,9 @@ fn main() {
}
}

pub fn make_app() -> Command<'static> {
Command::new("mdbook-catppuccin")
pub fn make_app() -> Command {
command!()
.name("mdbook-catppuccin")
.about("A mdbook preprocessor that implements catppuccin flavours as default themes")
.version(crate_version!())
.subcommand(
Expand Down Expand Up @@ -66,10 +67,11 @@ fn handle_preprocessing(pre: &Catppuccin) -> Result<(), Error> {
}

fn handle_supports(pre: &Catppuccin, sub_args: &ArgMatches) -> ! {
let renderer = sub_args.value_of("renderer").expect("Required argument");
let supported = pre.supports_renderer(renderer);
let renderer = sub_args
.get_one::<&str>("renderer")
.expect("Required argument");

if supported {
if pre.supports_renderer(renderer) {
process::exit(0);
} else {
process::exit(1);
Expand Down

0 comments on commit a1ddb9a

Please sign in to comment.