build.rs/src/main.rs

46 lines
1.2 KiB
Rust

use std::env;
use std::collections::HashMap;
use structopt::StructOpt;
mod log;
mod db;
mod dvcs;
mod cli;
fn main() {
let home_dir = env::var("HOME").expect("$HOME not defined. WTF?");
let base_dir = format!("{}/.git-build", home_dir);
let db = db::Database::from_folder(&base_dir);
let cmd = cli::Cli::from_args();
let tasks = if cmd.tasks.is_empty() {
db.tasks()
} else {
db.tasks_from(cmd.tasks).expect("Could not process the lsit of tasks given")
};
for task in tasks {
let mut context = HashMap::new();
context.insert("$i18n_task", task.name.to_str().expect("WTF"));
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
}
}
// Otherwise, it's a sourceless task
continue
}
// So the cloned repo is here maybe update?
}
}