diff --git a/Cargo.toml b/Cargo.toml index 8082d7eaca..b926a463b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,4 +70,3 @@ search = ["elasticlunr-rs", "ammonia"] [[bin]] doc = false name = "mdbook" -path = "src/bin/mdbook.rs" diff --git a/src/bin/build.rs b/src/cmd/build.rs similarity index 100% rename from src/bin/build.rs rename to src/cmd/build.rs diff --git a/src/bin/clean.rs b/src/cmd/clean.rs similarity index 100% rename from src/bin/clean.rs rename to src/cmd/clean.rs diff --git a/src/bin/init.rs b/src/cmd/init.rs similarity index 100% rename from src/bin/init.rs rename to src/cmd/init.rs diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs new file mode 100644 index 0000000000..df126fd191 --- /dev/null +++ b/src/cmd/mod.rs @@ -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; diff --git a/src/bin/serve.rs b/src/cmd/serve.rs similarity index 99% rename from src/bin/serve.rs rename to src/cmd/serve.rs index 4bef4e6058..aab58a8f4e 100644 --- a/src/bin/serve.rs +++ b/src/cmd/serve.rs @@ -11,7 +11,7 @@ use mdbook::utils; use mdbook::MDBook; use std; #[cfg(feature = "watch")] -use watch; +use super::watch; use {get_book_dir, open}; struct ErrorRecover; diff --git a/src/bin/test.rs b/src/cmd/test.rs similarity index 100% rename from src/bin/test.rs rename to src/cmd/test.rs diff --git a/src/bin/watch.rs b/src/cmd/watch.rs similarity index 100% rename from src/bin/watch.rs rename to src/cmd/watch.rs diff --git a/src/bin/mdbook.rs b/src/main.rs similarity index 76% rename from src/bin/mdbook.rs rename to src/main.rs index 9711c1d37b..8a1a2e9b84 100644 --- a/src/bin/mdbook.rs +++ b/src/main.rs @@ -18,14 +18,7 @@ use std::ffi::OsStr; use std::io::Write; use std::path::{Path, PathBuf}; -pub mod build; -pub mod clean; -pub mod init; -#[cfg(feature = "serve")] -pub mod serve; -pub mod test; -#[cfg(feature = "watch")] -pub mod watch; +mod cmd; const NAME: &'static str = "mdbook"; @@ -43,26 +36,26 @@ fn main() { try `mdbook --help`\n\ Source code for mdbook available \ at: https://github.com/rust-lang-nursery/mdBook") - .subcommand(init::make_subcommand()) - .subcommand(build::make_subcommand()) - .subcommand(test::make_subcommand()) - .subcommand(clean::make_subcommand()); + .subcommand(cmd::init::make_subcommand()) + .subcommand(cmd::build::make_subcommand()) + .subcommand(cmd::test::make_subcommand()) + .subcommand(cmd::clean::make_subcommand()); #[cfg(feature = "watch")] - let app = app.subcommand(watch::make_subcommand()); + let app = app.subcommand(cmd::watch::make_subcommand()); #[cfg(feature = "serve")] - let app = app.subcommand(serve::make_subcommand()); + let app = app.subcommand(cmd::serve::make_subcommand()); // Check which subcomamnd the user ran... let res = match app.get_matches().subcommand() { - ("init", Some(sub_matches)) => init::execute(sub_matches), - ("build", Some(sub_matches)) => build::execute(sub_matches), - ("clean", Some(sub_matches)) => clean::execute(sub_matches), + ("init", Some(sub_matches)) => cmd::init::execute(sub_matches), + ("build", Some(sub_matches)) => cmd::build::execute(sub_matches), + ("clean", Some(sub_matches)) => cmd::clean::execute(sub_matches), #[cfg(feature = "watch")] - ("watch", Some(sub_matches)) => watch::execute(sub_matches), + ("watch", Some(sub_matches)) => cmd::watch::execute(sub_matches), #[cfg(feature = "serve")] - ("serve", Some(sub_matches)) => serve::execute(sub_matches), - ("test", Some(sub_matches)) => test::execute(sub_matches), + ("serve", Some(sub_matches)) => cmd::serve::execute(sub_matches), + ("test", Some(sub_matches)) => cmd::test::execute(sub_matches), (_, _) => unreachable!(), };