use std::ffi::OsStr;
use std::fs;
use std::path::Path;
use util::process;
pub fn init
(path: P) -> ::Result<()>
where
P: AsRef,
{
fs::create_dir_all(&path)?;
process::inherit("pijul")
.arg("init")
.current_dir(path)
.status()
.map_err(Into::into)
.and_then(|st| match st.code() {
Some(0) => Ok(()),
st => Err(format!("command 'pijul' is exited with return code {:?}.", st).into()),
})
}
pub fn clone(url: U, path: P, args: I) -> ::Result<()>
where
P: AsRef,
U: AsRef,
I: IntoIterator- ,
S: AsRef,
{
let path = format!("{}", path.as_ref().display());
process::inherit("pijul")
.arg("clone")
.args(args)
.args(&[url.as_ref(), &path])
.status()
.map_err(Into::into)
.and_then(|st| match st.code() {
Some(0) => Ok(()),
st => Err(format!("command 'pijul' is exited with return code {:?}.", st).into()),
})
}