refactor: Move from deprecated SubCommand

This commit is contained in:
Ed Page 2022-01-18 16:19:40 -06:00
parent 372842aac6
commit 39eb78c88b
8 changed files with 16 additions and 16 deletions

View File

@ -1,5 +1,5 @@
use crate::nop_lib::Nop; use crate::nop_lib::Nop;
use clap::{App, Arg, ArgMatches, SubCommand}; use clap::{App, Arg, ArgMatches};
use mdbook::book::Book; use mdbook::book::Book;
use mdbook::errors::Error; use mdbook::errors::Error;
use mdbook::preprocess::{CmdPreprocessor, Preprocessor, PreprocessorContext}; use mdbook::preprocess::{CmdPreprocessor, Preprocessor, PreprocessorContext};
@ -11,7 +11,7 @@ pub fn make_app() -> App<'static> {
App::new("nop-preprocessor") App::new("nop-preprocessor")
.about("A mdbook preprocessor which does precisely nothing") .about("A mdbook preprocessor which does precisely nothing")
.subcommand( .subcommand(
SubCommand::with_name("supports") App::new("supports")
.arg(Arg::new("renderer").required(true)) .arg(Arg::new("renderer").required(true))
.about("Check whether a renderer is supported by this preprocessor"), .about("Check whether a renderer is supported by this preprocessor"),
) )

View File

@ -1,11 +1,11 @@
use crate::{get_book_dir, open}; use crate::{get_book_dir, open};
use clap::{App, ArgMatches, SubCommand}; use clap::{App, ArgMatches};
use mdbook::errors::Result; use mdbook::errors::Result;
use mdbook::MDBook; use mdbook::MDBook;
// Create clap subcommand arguments // Create clap subcommand arguments
pub fn make_subcommand<'help>() -> App<'help> { pub fn make_subcommand<'help>() -> App<'help> {
SubCommand::with_name("build") App::new("build")
.about("Builds a book from its markdown files") .about("Builds a book from its markdown files")
.arg_from_usage( .arg_from_usage(
"-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\

View File

@ -1,12 +1,12 @@
use crate::get_book_dir; use crate::get_book_dir;
use anyhow::Context; use anyhow::Context;
use clap::{App, ArgMatches, SubCommand}; use clap::{App, ArgMatches};
use mdbook::MDBook; use mdbook::MDBook;
use std::fs; use std::fs;
// Create clap subcommand arguments // Create clap subcommand arguments
pub fn make_subcommand<'help>() -> App<'help> { pub fn make_subcommand<'help>() -> App<'help> {
SubCommand::with_name("clean") App::new("clean")
.about("Deletes a built book") .about("Deletes a built book")
.arg_from_usage( .arg_from_usage(
"-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\

View File

@ -1,5 +1,5 @@
use crate::get_book_dir; use crate::get_book_dir;
use clap::{App, Arg, ArgMatches, SubCommand}; use clap::{App, Arg, ArgMatches};
use mdbook::config; use mdbook::config;
use mdbook::errors::Result; use mdbook::errors::Result;
use mdbook::MDBook; use mdbook::MDBook;
@ -9,7 +9,7 @@ use std::process::Command;
// Create clap subcommand arguments // Create clap subcommand arguments
pub fn make_subcommand<'help>() -> App<'help> { 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") .about("Creates the boilerplate structure and files for a new book")
// the {n} denotes a newline which will properly aligned in all help messages // the {n} denotes a newline which will properly aligned in all help messages
.arg_from_usage( .arg_from_usage(

View File

@ -1,7 +1,7 @@
#[cfg(feature = "watch")] #[cfg(feature = "watch")]
use super::watch; use super::watch;
use crate::{get_book_dir, open}; 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::sink::SinkExt;
use futures_util::StreamExt; use futures_util::StreamExt;
use mdbook::errors::*; use mdbook::errors::*;
@ -19,7 +19,7 @@ const LIVE_RELOAD_ENDPOINT: &str = "__livereload";
// Create clap subcommand arguments // Create clap subcommand arguments
pub fn make_subcommand<'help>() -> App<'help> { 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") .about("Serves a book at http://localhost:3000, and rebuilds it on changes")
.arg_from_usage( .arg_from_usage(
"-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\

View File

@ -1,11 +1,11 @@
use crate::get_book_dir; use crate::get_book_dir;
use clap::{App, Arg, ArgMatches, SubCommand}; use clap::{App, Arg, ArgMatches};
use mdbook::errors::Result; use mdbook::errors::Result;
use mdbook::MDBook; use mdbook::MDBook;
// Create clap subcommand arguments // Create clap subcommand arguments
pub fn make_subcommand<'help>() -> App<'help> { pub fn make_subcommand<'help>() -> App<'help> {
SubCommand::with_name("test") App::new("test")
.about("Tests that a book's Rust code samples compile") .about("Tests that a book's Rust code samples compile")
.arg_from_usage( .arg_from_usage(
"-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\

View File

@ -1,5 +1,5 @@
use crate::{get_book_dir, open}; use crate::{get_book_dir, open};
use clap::{App, ArgMatches, SubCommand}; use clap::{App, ArgMatches};
use mdbook::errors::Result; use mdbook::errors::Result;
use mdbook::utils; use mdbook::utils;
use mdbook::MDBook; use mdbook::MDBook;
@ -11,7 +11,7 @@ use std::time::Duration;
// Create clap subcommand arguments // Create clap subcommand arguments
pub fn make_subcommand<'help>() -> App<'help> { 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") .about("Watches a book's files and rebuilds it on changes")
.arg_from_usage( .arg_from_usage(
"-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\

View File

@ -5,7 +5,7 @@ extern crate log;
use anyhow::anyhow; use anyhow::anyhow;
use chrono::Local; use chrono::Local;
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; use clap::{App, AppSettings, Arg, ArgMatches};
use clap_complete::Shell; use clap_complete::Shell;
use env_logger::Builder; use env_logger::Builder;
use log::LevelFilter; use log::LevelFilter;
@ -78,7 +78,7 @@ fn create_clap_app() -> App<'static> {
.subcommand(cmd::test::make_subcommand()) .subcommand(cmd::test::make_subcommand())
.subcommand(cmd::clean::make_subcommand()) .subcommand(cmd::clean::make_subcommand())
.subcommand( .subcommand(
SubCommand::with_name("completions") App::new("completions")
.about("Generate shell completions for your shell to stdout") .about("Generate shell completions for your shell to stdout")
.arg( .arg(
Arg::new("shell") Arg::new("shell")