2020-04-30 16:53:49 +00:00
|
|
|
use std::env;
|
|
|
|
use std::collections::HashMap;
|
2020-05-01 10:48:22 +00:00
|
|
|
use structopt::StructOpt;
|
2020-06-01 14:56:24 +00:00
|
|
|
// For UNIX extended metadata
|
2020-04-30 16:53:49 +00:00
|
|
|
|
|
|
|
mod log;
|
2020-04-30 20:11:06 +00:00
|
|
|
mod db;
|
2020-04-30 23:45:48 +00:00
|
|
|
mod dvcs;
|
2020-05-01 10:48:22 +00:00
|
|
|
mod cli;
|
2020-06-01 14:56:24 +00:00
|
|
|
mod task;
|
2020-04-30 16:53:49 +00:00
|
|
|
|
2020-06-01 14:56:24 +00:00
|
|
|
fn main() -> Result<(), std::io::Error> {
|
2020-05-01 10:48:22 +00:00
|
|
|
let cmd = cli::Cli::from_args();
|
2020-11-23 19:07:38 +00:00
|
|
|
let base_dir: String = cmd.basedir().to_str().unwrap().into();
|
2020-05-01 10:48:22 +00:00
|
|
|
|
2020-05-01 11:19:33 +00:00
|
|
|
let tasks = if cmd.tasks.is_empty() {
|
2020-06-10 11:04:35 +00:00
|
|
|
task::from_dir(&base_dir).expect("Could not load DB")
|
2020-05-01 11:19:33 +00:00
|
|
|
} else {
|
2020-06-10 11:04:35 +00:00
|
|
|
task::from_dir_and_list(&base_dir, cmd.tasks).expect("Could not load given tasks")
|
2020-05-01 11:19:33 +00:00
|
|
|
};
|
2020-06-10 11:04:35 +00:00
|
|
|
|
2020-06-01 14:56:24 +00:00
|
|
|
for (task_name, task) in tasks.iter() {
|
2020-04-30 23:45:48 +00:00
|
|
|
let mut context = HashMap::new();
|
2020-06-01 14:56:24 +00:00
|
|
|
context.insert("$i18n_task", task_name.as_str());
|
2020-04-30 23:45:48 +00:00
|
|
|
log::debug("found_task", Some(&context));
|
|
|
|
if task.cloned == false {
|
|
|
|
// Maybe the task has a source we should clone?
|
|
|
|
if let Some(source) = &task.source {
|
2020-04-30 20:11:06 +00:00
|
|
|
|
2020-04-30 23:45:48 +00:00
|
|
|
if !task.dvcs.clone(source) {
|
|
|
|
context.insert("$i18n_source", &source);
|
|
|
|
log::error("clone_failed", Some(&context));
|
|
|
|
// Skip further processing
|
2020-05-01 10:48:22 +00:00
|
|
|
continue
|
2020-04-30 23:45:48 +00:00
|
|
|
}
|
2020-07-01 15:38:27 +00:00
|
|
|
// New repo just cloned
|
2020-04-30 23:45:48 +00:00
|
|
|
}
|
|
|
|
// Otherwise, it's a sourceless task
|
|
|
|
continue
|
|
|
|
}
|
2020-07-01 15:38:27 +00:00
|
|
|
// So the cloned repo is already here maybe update?
|
2020-04-30 23:45:48 +00:00
|
|
|
}
|
2020-06-01 14:56:24 +00:00
|
|
|
Ok(())
|
2020-04-30 16:53:49 +00:00
|
|
|
}
|