From 39eb78c88b627e14b642a37d33d51f9f29647f16 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 18 Jan 2022 16:19:40 -0600 Subject: [PATCH] refactor: Move from deprecated SubCommand --- examples/nop-preprocessor.rs | 4 ++-- src/cmd/build.rs | 4 ++-- src/cmd/clean.rs | 4 ++-- src/cmd/init.rs | 4 ++-- src/cmd/serve.rs | 4 ++-- src/cmd/test.rs | 4 ++-- src/cmd/watch.rs | 4 ++-- src/main.rs | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/nop-preprocessor.rs b/examples/nop-preprocessor.rs index 69fb87f4..ace40093 100644 --- a/examples/nop-preprocessor.rs +++ b/examples/nop-preprocessor.rs @@ -1,5 +1,5 @@ use crate::nop_lib::Nop; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use mdbook::book::Book; use mdbook::errors::Error; use mdbook::preprocess::{CmdPreprocessor, Preprocessor, PreprocessorContext}; @@ -11,7 +11,7 @@ pub fn make_app() -> App<'static> { App::new("nop-preprocessor") .about("A mdbook preprocessor which does precisely nothing") .subcommand( - SubCommand::with_name("supports") + App::new("supports") .arg(Arg::new("renderer").required(true)) .about("Check whether a renderer is supported by this preprocessor"), ) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index fd421a39..f9583d73 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1,11 +1,11 @@ use crate::{get_book_dir, open}; -use clap::{App, ArgMatches, SubCommand}; +use clap::{App, ArgMatches}; use mdbook::errors::Result; use mdbook::MDBook; // Create clap subcommand arguments pub fn make_subcommand<'help>() -> App<'help> { - SubCommand::with_name("build") + App::new("build") .about("Builds a book from its markdown files") .arg_from_usage( "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ diff --git a/src/cmd/clean.rs b/src/cmd/clean.rs index 0f368dda..0b8f8974 100644 --- a/src/cmd/clean.rs +++ b/src/cmd/clean.rs @@ -1,12 +1,12 @@ use crate::get_book_dir; use anyhow::Context; -use clap::{App, ArgMatches, SubCommand}; +use clap::{App, ArgMatches}; use mdbook::MDBook; use std::fs; // Create clap subcommand arguments pub fn make_subcommand<'help>() -> App<'help> { - SubCommand::with_name("clean") + App::new("clean") .about("Deletes a built book") .arg_from_usage( "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ diff --git a/src/cmd/init.rs b/src/cmd/init.rs index b9e08872..500e3743 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -1,5 +1,5 @@ use crate::get_book_dir; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use mdbook::config; use mdbook::errors::Result; use mdbook::MDBook; @@ -9,7 +9,7 @@ use std::process::Command; // Create clap subcommand arguments pub fn make_subcommand<'help>() -> App<'help> { - SubCommand::with_name("init") + App::new("init") .about("Creates the boilerplate structure and files for a new book") // the {n} denotes a newline which will properly aligned in all help messages .arg_from_usage( diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index fcc06b40..5b3ef696 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -1,7 +1,7 @@ #[cfg(feature = "watch")] use super::watch; use crate::{get_book_dir, open}; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use futures_util::sink::SinkExt; use futures_util::StreamExt; use mdbook::errors::*; @@ -19,7 +19,7 @@ const LIVE_RELOAD_ENDPOINT: &str = "__livereload"; // Create clap subcommand arguments pub fn make_subcommand<'help>() -> App<'help> { - SubCommand::with_name("serve") + App::new("serve") .about("Serves a book at http://localhost:3000, and rebuilds it on changes") .arg_from_usage( "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ diff --git a/src/cmd/test.rs b/src/cmd/test.rs index ba7aa6c9..b3e27325 100644 --- a/src/cmd/test.rs +++ b/src/cmd/test.rs @@ -1,11 +1,11 @@ use crate::get_book_dir; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use mdbook::errors::Result; use mdbook::MDBook; // Create clap subcommand arguments pub fn make_subcommand<'help>() -> App<'help> { - SubCommand::with_name("test") + App::new("test") .about("Tests that a book's Rust code samples compile") .arg_from_usage( "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 992246ae..103a53a0 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -1,5 +1,5 @@ use crate::{get_book_dir, open}; -use clap::{App, ArgMatches, SubCommand}; +use clap::{App, ArgMatches}; use mdbook::errors::Result; use mdbook::utils; use mdbook::MDBook; @@ -11,7 +11,7 @@ use std::time::Duration; // Create clap subcommand arguments pub fn make_subcommand<'help>() -> App<'help> { - SubCommand::with_name("watch") + App::new("watch") .about("Watches a book's files and rebuilds it on changes") .arg_from_usage( "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ diff --git a/src/main.rs b/src/main.rs index 37c85c43..d68afc41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ extern crate log; use anyhow::anyhow; use chrono::Local; -use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use clap::{App, AppSettings, Arg, ArgMatches}; use clap_complete::Shell; use env_logger::Builder; use log::LevelFilter; @@ -78,7 +78,7 @@ fn create_clap_app() -> App<'static> { .subcommand(cmd::test::make_subcommand()) .subcommand(cmd::clean::make_subcommand()) .subcommand( - SubCommand::with_name("completions") + App::new("completions") .about("Generate shell completions for your shell to stdout") .arg( Arg::new("shell")