diff --git a/src/main.rs b/src/main.rs index b0fb4ae4..47f71402 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,34 +1,18 @@ -#[cfg(target_os = "freebsd")] -mod freebsd; -#[cfg(target_os = "linux")] -mod linux; -#[cfg(target_os = "macos")] -mod macos; -#[cfg(unix)] -mod tmux; -#[cfg(unix)] -mod unix; -#[cfg(target_os = "windows")] -mod windows; - mod config; mod ctrlc; mod error; mod executor; -mod generic; -mod git; -mod node; mod report; #[cfg(feature = "self-update")] mod self_update; +mod steps; mod terminal; mod utils; -mod vim; use self::config::Config; use self::error::{Error, ErrorKind}; -use self::git::{Git, Repositories}; use self::report::Report; +use self::steps::*; use self::terminal::*; use failure::{Fail, ResultExt}; use std::borrow::Cow; @@ -78,8 +62,8 @@ fn run() -> Result<(), Error> { env_logger::init(); let base_dirs = directories::BaseDirs::new().ok_or(ErrorKind::NoBaseDirectories)?; - let git = Git::new(); - let mut git_repos = Repositories::new(&git); + let git = git::Git::new(); + let mut git_repos = git::Repositories::new(&git); let config = Config::read(&base_dirs)?; let mut report = Report::new(); diff --git a/src/emacs.el b/src/steps/emacs.el similarity index 100% rename from src/emacs.el rename to src/steps/emacs.el diff --git a/src/generic.rs b/src/steps/generic.rs similarity index 97% rename from src/generic.rs rename to src/steps/generic.rs index df6b7260..b20a1aad 100644 --- a/src/generic.rs +++ b/src/steps/generic.rs @@ -1,7 +1,7 @@ -use super::error::{Error, ErrorKind}; -use super::executor::Executor; -use super::terminal::print_separator; -use super::utils::{self, Check, PathExt}; +use crate::error::{Error, ErrorKind}; +use crate::executor::Executor; +use crate::terminal::print_separator; +use crate::utils::{self, Check, PathExt}; use directories::BaseDirs; use failure::ResultExt; use std::path::PathBuf; diff --git a/src/git.rs b/src/steps/git.rs similarity index 95% rename from src/git.rs rename to src/steps/git.rs index 1d3485b8..e0a5e3f1 100644 --- a/src/git.rs +++ b/src/steps/git.rs @@ -1,7 +1,7 @@ -use super::error::Error; -use super::executor::Executor; -use super::terminal::print_separator; -use super::utils::{which, Check}; +use crate::error::Error; +use crate::executor::Executor; +use crate::terminal::print_separator; +use crate::utils::{which, Check}; use log::{debug, error}; use std::collections::HashSet; use std::io; diff --git a/src/steps/mod.rs b/src/steps/mod.rs new file mode 100644 index 00000000..789ab6fd --- /dev/null +++ b/src/steps/mod.rs @@ -0,0 +1,9 @@ +pub mod generic; +pub mod git; +pub mod node; +pub mod os; +#[cfg(unix)] +pub mod tmux; +pub mod vim; + +pub use self::os::*; diff --git a/src/node.rs b/src/steps/node.rs similarity index 92% rename from src/node.rs rename to src/steps/node.rs index 4e1e50c2..f0114415 100644 --- a/src/node.rs +++ b/src/steps/node.rs @@ -1,7 +1,7 @@ -use super::error::{Error, ErrorKind}; -use super::executor::Executor; -use super::terminal::print_separator; -use super::utils::{which, Check, PathExt}; +use crate::error::{Error, ErrorKind}; +use crate::executor::Executor; +use crate::terminal::print_separator; +use crate::utils::{which, Check, PathExt}; use directories::BaseDirs; use failure::ResultExt; use std::path::PathBuf; diff --git a/src/freebsd.rs b/src/steps/os/freebsd.rs similarity index 91% rename from src/freebsd.rs rename to src/steps/os/freebsd.rs index b4817ee2..30c0a72c 100644 --- a/src/freebsd.rs +++ b/src/steps/os/freebsd.rs @@ -1,7 +1,7 @@ -use super::error::{Error, ErrorKind}; -use super::executor::Executor; -use super::terminal::{print_separator, print_warning}; -use super::utils::Check; +use crate::error::{Error, ErrorKind}; +use crate::executor::Executor; +use crate::terminal::{print_separator, print_warning}; +use crate::utils::Check; use failure::ResultExt; use std::path::PathBuf; use std::process::Command; diff --git a/src/linux.rs b/src/steps/os/linux.rs similarity index 98% rename from src/linux.rs rename to src/steps/os/linux.rs index 5f8be0ba..b92656e7 100644 --- a/src/linux.rs +++ b/src/steps/os/linux.rs @@ -1,7 +1,7 @@ -use super::error::{Error, ErrorKind}; -use super::executor::Executor; -use super::terminal::{print_separator, print_warning}; -use super::utils::{which, Check}; +use crate::error::{Error, ErrorKind}; +use crate::executor::Executor; +use crate::terminal::{print_separator, print_warning}; +use crate::utils::{which, Check}; use failure::ResultExt; use std::fs; use std::path::PathBuf; diff --git a/src/macos.rs b/src/steps/os/macos.rs similarity index 76% rename from src/macos.rs rename to src/steps/os/macos.rs index b4f8a912..184247b3 100644 --- a/src/macos.rs +++ b/src/steps/os/macos.rs @@ -1,7 +1,7 @@ -use super::error::Error; -use super::executor::Executor; -use super::terminal::print_separator; -use super::utils::Check; +use crate::error::Error; +use crate::executor::Executor; +use crate::terminal::print_separator; +use crate::utils::Check; #[must_use] pub fn upgrade_macos(dry_run: bool) -> Option<(&'static str, bool)> { diff --git a/src/steps/os/mod.rs b/src/steps/os/mod.rs new file mode 100644 index 00000000..70d59b1c --- /dev/null +++ b/src/steps/os/mod.rs @@ -0,0 +1,10 @@ +#[cfg(target_os = "freebsd")] +pub mod freebsd; +#[cfg(target_os = "linux")] +pub mod linux; +#[cfg(target_os = "macos")] +pub mod macos; +#[cfg(unix)] +pub mod unix; +#[cfg(target_os = "windows")] +pub mod windows; diff --git a/src/unix.rs b/src/steps/os/unix.rs similarity index 95% rename from src/unix.rs rename to src/steps/os/unix.rs index ed445566..de4d34cb 100644 --- a/src/unix.rs +++ b/src/steps/os/unix.rs @@ -1,7 +1,7 @@ -use super::error::Error; -use super::executor::Executor; -use super::terminal::print_separator; -use super::utils::{which, Check}; +use crate::error::Error; +use crate::executor::Executor; +use crate::terminal::print_separator; +use crate::utils::{which, Check}; use directories::BaseDirs; pub fn run_zplug(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { diff --git a/src/windows.rs b/src/steps/os/windows.rs similarity index 96% rename from src/windows.rs rename to src/steps/os/windows.rs index 4efbda20..b40ac55d 100644 --- a/src/windows.rs +++ b/src/steps/os/windows.rs @@ -1,7 +1,7 @@ -use super::error::{Error, ErrorKind}; -use super::executor::Executor; -use super::terminal::print_separator; -use super::utils::{self, which, Check}; +use crate::error::{Error, ErrorKind}; +use crate::executor::Executor; +use crate::terminal::print_separator; +use crate::utils::{self, which, Check}; use failure::ResultExt; use log::error; use std::path::PathBuf; diff --git a/src/tmux.rs b/src/steps/tmux.rs similarity index 92% rename from src/tmux.rs rename to src/steps/tmux.rs index cae45dd7..41e64dfa 100644 --- a/src/tmux.rs +++ b/src/steps/tmux.rs @@ -1,8 +1,7 @@ -use super::error::{Error, ErrorKind}; -use super::executor::Executor; -use super::terminal::print_separator; -use super::utils::which; -use super::utils::{Check, PathExt}; +use crate::error::{Error, ErrorKind}; +use crate::executor::Executor; +use crate::terminal::print_separator; +use crate::utils::{which, Check, PathExt}; use directories::BaseDirs; use failure::ResultExt; use std::env; diff --git a/src/vim.rs b/src/steps/vim.rs similarity index 95% rename from src/vim.rs rename to src/steps/vim.rs index 73701caa..fcbb4699 100644 --- a/src/vim.rs +++ b/src/steps/vim.rs @@ -1,7 +1,7 @@ -use super::error::Error; -use super::executor::Executor; -use super::terminal::print_separator; -use super::utils::{which, Check, PathExt}; +use crate::error::Error; +use crate::executor::Executor; +use crate::terminal::print_separator; +use crate::utils::{which, Check, PathExt}; use directories::BaseDirs; use std::fs; use std::path::PathBuf;