mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-15 07:12:35 +00:00
Move subcommand modules to match cargo conventions
This commit is contained in:
parent
0f89abb1c7
commit
f300a21a47
9 changed files with 24 additions and 22 deletions
|
@ -70,4 +70,3 @@ search = ["elasticlunr-rs", "ammonia"]
|
||||||
[[bin]]
|
[[bin]]
|
||||||
doc = false
|
doc = false
|
||||||
name = "mdbook"
|
name = "mdbook"
|
||||||
path = "src/bin/mdbook.rs"
|
|
||||||
|
|
10
src/cmd/mod.rs
Normal file
10
src/cmd/mod.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/// Subcommand modules for the `mdbook` binary.
|
||||||
|
|
||||||
|
pub mod build;
|
||||||
|
pub mod clean;
|
||||||
|
pub mod init;
|
||||||
|
#[cfg(feature = "serve")]
|
||||||
|
pub mod serve;
|
||||||
|
pub mod test;
|
||||||
|
#[cfg(feature = "watch")]
|
||||||
|
pub mod watch;
|
|
@ -11,7 +11,7 @@ use mdbook::utils;
|
||||||
use mdbook::MDBook;
|
use mdbook::MDBook;
|
||||||
use std;
|
use std;
|
||||||
#[cfg(feature = "watch")]
|
#[cfg(feature = "watch")]
|
||||||
use watch;
|
use super::watch;
|
||||||
use {get_book_dir, open};
|
use {get_book_dir, open};
|
||||||
|
|
||||||
struct ErrorRecover;
|
struct ErrorRecover;
|
|
@ -18,14 +18,7 @@ use std::ffi::OsStr;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
pub mod build;
|
mod cmd;
|
||||||
pub mod clean;
|
|
||||||
pub mod init;
|
|
||||||
#[cfg(feature = "serve")]
|
|
||||||
pub mod serve;
|
|
||||||
pub mod test;
|
|
||||||
#[cfg(feature = "watch")]
|
|
||||||
pub mod watch;
|
|
||||||
|
|
||||||
const NAME: &'static str = "mdbook";
|
const NAME: &'static str = "mdbook";
|
||||||
|
|
||||||
|
@ -43,26 +36,26 @@ fn main() {
|
||||||
try `mdbook <command> --help`\n\
|
try `mdbook <command> --help`\n\
|
||||||
Source code for mdbook available \
|
Source code for mdbook available \
|
||||||
at: https://github.com/rust-lang-nursery/mdBook")
|
at: https://github.com/rust-lang-nursery/mdBook")
|
||||||
.subcommand(init::make_subcommand())
|
.subcommand(cmd::init::make_subcommand())
|
||||||
.subcommand(build::make_subcommand())
|
.subcommand(cmd::build::make_subcommand())
|
||||||
.subcommand(test::make_subcommand())
|
.subcommand(cmd::test::make_subcommand())
|
||||||
.subcommand(clean::make_subcommand());
|
.subcommand(cmd::clean::make_subcommand());
|
||||||
|
|
||||||
#[cfg(feature = "watch")]
|
#[cfg(feature = "watch")]
|
||||||
let app = app.subcommand(watch::make_subcommand());
|
let app = app.subcommand(cmd::watch::make_subcommand());
|
||||||
#[cfg(feature = "serve")]
|
#[cfg(feature = "serve")]
|
||||||
let app = app.subcommand(serve::make_subcommand());
|
let app = app.subcommand(cmd::serve::make_subcommand());
|
||||||
|
|
||||||
// Check which subcomamnd the user ran...
|
// Check which subcomamnd the user ran...
|
||||||
let res = match app.get_matches().subcommand() {
|
let res = match app.get_matches().subcommand() {
|
||||||
("init", Some(sub_matches)) => init::execute(sub_matches),
|
("init", Some(sub_matches)) => cmd::init::execute(sub_matches),
|
||||||
("build", Some(sub_matches)) => build::execute(sub_matches),
|
("build", Some(sub_matches)) => cmd::build::execute(sub_matches),
|
||||||
("clean", Some(sub_matches)) => clean::execute(sub_matches),
|
("clean", Some(sub_matches)) => cmd::clean::execute(sub_matches),
|
||||||
#[cfg(feature = "watch")]
|
#[cfg(feature = "watch")]
|
||||||
("watch", Some(sub_matches)) => watch::execute(sub_matches),
|
("watch", Some(sub_matches)) => cmd::watch::execute(sub_matches),
|
||||||
#[cfg(feature = "serve")]
|
#[cfg(feature = "serve")]
|
||||||
("serve", Some(sub_matches)) => serve::execute(sub_matches),
|
("serve", Some(sub_matches)) => cmd::serve::execute(sub_matches),
|
||||||
("test", Some(sub_matches)) => test::execute(sub_matches),
|
("test", Some(sub_matches)) => cmd::test::execute(sub_matches),
|
||||||
(_, _) => unreachable!(),
|
(_, _) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue