Basedir can be configured with -b/--basedir
This commit is contained in:
parent
5b99ff9550
commit
25ea54143c
17
src/cli.rs
17
src/cli.rs
|
@ -1,4 +1,6 @@
|
|||
use structopt::StructOpt;
|
||||
use std::path::PathBuf;
|
||||
use std::env;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "git-build", about = "Update your repositories and trigger tasks")]
|
||||
|
@ -7,6 +9,21 @@ pub struct Cli {
|
|||
#[structopt(short = "f", long = "force")]
|
||||
pub force: bool,
|
||||
|
||||
#[structopt(short = "b", long = "basedir")]
|
||||
pub basedir: Option<String>,
|
||||
|
||||
//#[structopt(def)]
|
||||
pub tasks: Vec<String>,
|
||||
}
|
||||
|
||||
impl Cli {
|
||||
pub fn basedir(&self) -> PathBuf {
|
||||
if let Some(basedir) = &self.basedir {
|
||||
PathBuf::from(basedir)
|
||||
} else {
|
||||
let mut home_path = PathBuf::from(env::var("HOME").expect("No $HOME in env"));
|
||||
home_path.push(".forgebuild");
|
||||
home_path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,8 @@ 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!("{}/.forgebuild", home_dir);
|
||||
|
||||
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")
|
||||
|
@ -24,7 +21,6 @@ fn main() -> Result<(), std::io::Error> {
|
|||
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue