use std::{
io::{Error, ErrorKind},
path::{Path, PathBuf},
};
use crate::Result;
pub (crate) const CMD_LIST: &str = "list";
pub (crate) const OPTION_PORCELAIN: &str = "--porcelain";
pub (crate) const OPTION_Z: &str = "-z";
#[derive(Debug, Eq, PartialEq, Hash)]
pub struct WorkTree {
path: PathBuf,
}
impl WorkTree {
pub (crate) fn make<P>(path: P) -> Result<Self> where P: AsRef<Path> {
let path = path.as_ref().to_path_buf().canonicalize()?;
if path.is_dir() {
Ok(Self {
path,
})
} else {
Err(Error::new(ErrorKind::InvalidInput, __!("Not a directory: {:?}", path)))
}
}
pub fn path(&self) -> &Path {
&self.path
}
}