49 lines
1.4 KiB
Rust
49 lines
1.4 KiB
Rust
use std::env;
|
|
use std::collections::HashMap;
|
|
use structopt::StructOpt;
|
|
// For UNIX extended metadata
|
|
|
|
mod log;
|
|
mod db;
|
|
mod dvcs;
|
|
mod cli;
|
|
mod task;
|
|
|
|
fn main() -> Result<(), std::io::Error> {
|
|
|
|
let home_dir = env::var("HOME").expect("$HOME not defined. WTF?");
|
|
let base_dir = format!("{}/.git-build", home_dir);
|
|
|
|
let cmd = cli::Cli::from_args();
|
|
|
|
let tasks = if cmd.tasks.is_empty() {
|
|
task::from_dir(&base_dir).expect("Could not load DB")
|
|
} else {
|
|
task::from_dir_and_list(&base_dir, cmd.tasks).expect("Could not load given tasks")
|
|
};
|
|
|
|
for (task_name, task) in tasks.iter() {
|
|
let mut context = HashMap::new();
|
|
//context.insert("$i18n_task", task_name.to_str().expect("WTF"));
|
|
context.insert("$i18n_task", task_name.as_str());
|
|
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 {
|
|
|
|
if !task.dvcs.clone(source) {
|
|
context.insert("$i18n_source", &source);
|
|
log::error("clone_failed", Some(&context));
|
|
// Skip further processing
|
|
continue
|
|
}
|
|
// New repo just cloned
|
|
}
|
|
// Otherwise, it's a sourceless task
|
|
continue
|
|
}
|
|
// So the cloned repo is already here maybe update?
|
|
}
|
|
Ok(())
|
|
}
|