homesync/src/lib.rs

43 lines
876 B
Rust
Raw Normal View History

pub mod config;
pub mod copy;
2021-12-30 13:37:53 +00:00
pub mod daemon;
pub mod git;
pub mod path;
2021-12-29 16:49:24 +00:00
2021-12-30 13:37:53 +00:00
use config::PathConfig;
2022-01-07 11:11:25 +00:00
use std::error::Error;
type Result = std::result::Result<(), Box<dyn Error>>;
pub fn run_apply(config: PathConfig, file: Option<&str>) -> Result {
copy::apply(&config, file)?;
Ok(())
}
pub fn run_daemon(config: PathConfig, freq_secs: u64) -> Result {
daemon::launch(config, freq_secs)?;
2021-12-30 13:37:53 +00:00
Ok(())
}
pub fn run_list(config: PathConfig) -> Result {
config::list_packages(config);
2021-12-30 13:37:53 +00:00
Ok(())
}
pub fn run_push(config: PathConfig) -> Result {
let mut repo = git::init(&config)?;
git::push(&config, &mut repo)?;
Ok(())
}
2022-01-07 11:32:34 +00:00
2022-01-07 13:45:05 +00:00
pub fn run_pull(config: PathConfig) -> Result {
2022-01-08 15:31:46 +00:00
let mut repo = git::init(&config)?;
git::pull(&config, &mut repo)?;
2022-01-07 13:45:05 +00:00
Ok(())
}
2022-01-07 11:32:34 +00:00
pub fn run_stage(config: PathConfig) -> Result {
copy::stage(&config)?;
2022-01-07 11:32:34 +00:00
Ok(())
}