use structopt::StructOpt; use std::path::PathBuf; use std::env; #[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, //#[structopt(def)] pub tasks: Vec, } 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 } } }