use std::path::{Path, PathBuf};
#[derive(Clone, Debug)]
pub struct RmOpts {
pub path: PathBuf,
pub staged: bool,
pub recursive: bool,
}
impl Default for RmOpts {
fn default() -> Self {
Self::new()
}
}
impl RmOpts {
pub fn new() -> RmOpts {
RmOpts {
path: PathBuf::from(""),
staged: false,
recursive: false,
}
}
pub fn from_path<P: AsRef<Path>>(path: P) -> RmOpts {
RmOpts {
path: path.as_ref().to_owned(),
staged: false,
recursive: false,
}
}
pub fn from_staged_path<P: AsRef<Path>>(path: P) -> RmOpts {
RmOpts {
path: path.as_ref().to_owned(),
staged: true,
recursive: false,
}
}
pub fn from_path_recursive<P: AsRef<Path>>(path: P) -> RmOpts {
RmOpts {
path: path.as_ref().to_owned(),
staged: false,
recursive: true,
}
}
pub fn from_path_opts<P: AsRef<Path>>(path: P, opts: &RmOpts) -> RmOpts {
RmOpts {
path: path.as_ref().to_owned(),
staged: opts.staged,
recursive: opts.recursive,
}
}
}