2021-12-30 02:47:34 +00:00
|
|
|
pub mod config;
|
2022-01-08 20:34:09 +00:00
|
|
|
pub mod copy;
|
2021-12-30 13:37:53 +00:00
|
|
|
pub mod daemon;
|
2021-12-31 15:17:55 +00:00
|
|
|
pub mod git;
|
2021-12-30 19:17:42 +00:00
|
|
|
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;
|
2021-12-29 13:15:19 +00:00
|
|
|
|
2022-01-02 18:48:18 +00:00
|
|
|
type Result = std::result::Result<(), Box<dyn Error>>;
|
|
|
|
|
2022-01-08 20:34:09 +00:00
|
|
|
pub fn run_apply(config: PathConfig, file: Option<&str>) -> Result {
|
|
|
|
copy::apply(&config, file)?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-01-02 18:48:18 +00:00
|
|
|
pub fn run_daemon(config: PathConfig, freq_secs: u64) -> Result {
|
2022-01-08 20:34:09 +00:00
|
|
|
daemon::launch(config, freq_secs)?;
|
2021-12-30 13:37:53 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-01-02 18:48:18 +00:00
|
|
|
pub fn run_list(config: PathConfig) -> Result {
|
2022-01-01 14:24:01 +00:00
|
|
|
config::list_packages(config);
|
2021-12-30 13:37:53 +00:00
|
|
|
Ok(())
|
2021-12-29 13:15:19 +00:00
|
|
|
}
|
2022-01-06 13:54:46 +00:00
|
|
|
|
|
|
|
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 {
|
2022-01-08 20:34:09 +00:00
|
|
|
copy::stage(&config)?;
|
2022-01-07 11:32:34 +00:00
|
|
|
Ok(())
|
|
|
|
}
|