use crate::{
error::{DotlingError, Result},
git::Git,
printer::Printer,
repo,
};
const DEFAULT_MESSAGE: &str = "dotling: update dotfiles";
pub fn run(printer: &Printer, message: Option<&str>) -> Result<()> {
let repo_root = repo::get_repo_root()?;
let git = Git::new(repo_root.clone());
if !git.has_remote()? {
return Err(DotlingError::NoRemote);
}
let msg = message.unwrap_or(DEFAULT_MESSAGE);
printer.action("stage", &repo_root);
git.stage_all()?;
printer.action("commit", &repo_root);
git.commit(msg)?;
printer.action("push", &repo_root);
git.push()?;
printer.success("Pushed successfully.");
Ok(())
}