build.rs/src/main.rs

46 lines
1.2 KiB
Rust
Raw Normal View History

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-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-04-30 16:53:49 +00:00
fn main() {
let home_dir = env::var("HOME").expect("$HOME not defined. WTF?");
let base_dir = format!("{}/.git-build", home_dir);
2020-04-30 20:11:06 +00:00
let db = db::Database::from_folder(&base_dir);
2020-05-01 10:48:22 +00:00
let cmd = cli::Cli::from_args();
2020-05-01 11:19:33 +00:00
let tasks = if cmd.tasks.is_empty() {
db.tasks()
} else {
db.tasks_from(cmd.tasks).expect("Could not process the lsit of tasks given")
};
2020-04-30 20:11:06 +00:00
2020-05-01 11:19:33 +00:00
for task in tasks {
2020-04-30 23:45:48 +00:00
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 {
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
}
}
// Otherwise, it's a sourceless task
continue
}
// So the cloned repo is here maybe update?
}
2020-04-30 16:53:49 +00:00
}