Status: WIP Completed: * Fixed flagged clippy lints * Moved qemu(), main.rs::mount() and chroot() to the tools module. * Moved constants in main.rs to constants.rs (including base packages array) * Renamed Presets struct to PresetsCollection to avoid confusion with Preset struct * Moved main() to the top of main.rs to highlight general logic path * Added comments and docstrings to some functions * Removed some uses of `use foo::*` to make the source of imported functions and structs clearer TODO: * Move remaining code in main.rs to modules (except main()) * Break up create() function in to separate steps * Log every command run (with arguments) to debug! when verbose flag is used * Add docstrings for remaining functions and document constants (e.g. why noatime is used) * Remove remaining uses of `use foo::*` * Consider renaming/moving tools module to address tool:: vs. Tool:: confusion
31 lines
527 B
Rust
31 lines
527 B
Rust
mod chroot;
|
|
mod mount;
|
|
mod qemu;
|
|
|
|
pub use chroot::chroot;
|
|
pub use mount::mount;
|
|
pub use qemu::qemu;
|
|
|
|
use crate::error::*;
|
|
use failure::ResultExt;
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
use which::which;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Tool {
|
|
exec: PathBuf,
|
|
}
|
|
|
|
impl Tool {
|
|
pub fn find(name: &'static str) -> Result<Self, Error> {
|
|
Ok(Self {
|
|
exec: which(name).context(ErrorKind::NoTool(name))?,
|
|
})
|
|
}
|
|
|
|
pub fn execute(&self) -> Command {
|
|
Command::new(&self.exec)
|
|
}
|
|
}
|