Skip to content

Commit

Permalink
Move to current clap
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddrysdale committed Apr 4, 2024
1 parent 2bf638f commit 216d677
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 83 deletions.
81 changes: 5 additions & 76 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 @@ -10,7 +10,7 @@ keywords = ["mdbook", "index"]
categories = ["text-processing"]

[dependencies]
clap = "2.*"
clap = "4.5.*"
env_logger = "0.11.*"
lazy_static = "1.*"
log = "0.4.*"
Expand Down
15 changes: 9 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//! ```
//!
use clap::{App, Arg, SubCommand};
use clap::{Arg, Command};
use lazy_static::lazy_static;
use mdbook::{
book::Book,
Expand Down Expand Up @@ -68,22 +68,25 @@ const NEST_UNDER_INDENT: &str = "      ";
/// ^^^^^
const USE_NAMES_INDENT: &str = "      ";

pub fn make_app() -> App<'static, 'static> {
App::new("index-preprocessor")
pub fn make_app() -> Command {
Command::new("index-preprocessor")
.about("An mdbook preprocessor which collates an index")
.subcommand(
SubCommand::with_name("supports")
.arg(Arg::with_name("renderer").required(true))
Command::new("supports")
.arg(Arg::new("renderer").required(true))
.about("Check whether a renderer is supported by this preprocessor"),
)
}

fn main() {
env_logger::init();

let matches = make_app().get_matches();

if let Some(sub_args) = matches.subcommand_matches("supports") {
let renderer = sub_args.value_of("renderer").expect("Required argument");
let renderer = sub_args
.get_one::<String>("renderer")
.expect("Required argument");
let supported = Index::supports_renderer(renderer);

// Signal whether the renderer is supported by exiting with 1 or 0.
Expand Down

0 comments on commit 216d677

Please sign in to comment.