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 cmd = cli::Cli::from_args(); let base_dir: String = cmd.basedir().to_str().unwrap().into(); 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") }; let (config_folder, ignored_tasks) = task::config(&std::path::Path::new(&base_dir)); for (task_name, task) in tasks.iter() { if ignored_tasks.contains(&task_name) { // Skip task which has CONFIG/task.ignore continue; } println!("TASK: {:?}", task_name); let mut context = HashMap::new(); context.insert("$i18n_task", task_name.as_str()); log::debug("found_task", Some(&context)); // Maybe the task has a source we should clone? if let Some(source) = &task.source { if task.cloned == false { if !task.dvcs.clone(source) { context.insert("$i18n_source", &source); log::error("clone_failed", Some(&context)); // Skip further processing continue } // New repo just cloned // TODO: submodule and submodule updates println!("Downloaded source for {}", task_name); task.run(); } // So the cloned repo is already here maybe update? // Let's say there was an update and run println!("Task {} already exists, run it", task_name); task.run(); } else { println!("Taks {} doesn't have a source, run it", task_name); task.run_once(); } } Ok(()) }