build.rs/src/cli.rs

34 lines
825 B
Rust

use std::env;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "git-build",
about = "Update your repositories and trigger tasks"
)]
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)
.canonicalize()
.expect("failed to expand relative path")
} else {
let mut home_path = PathBuf::from(env::var("HOME").expect("No $HOME in env"));
home_path.push(".forgebuild");
home_path
}
}
}