I am using the crate structopt for my cli program. I want to set home directory as default, if output dir in args not passed. Below is my code, please suggest me how i can implement.
Command.rs
pub enum Command {
#[structopt(name = "init")]
Init(InitCmd),
}
impl Command {
/// Wrapper around `StructOpt::from_args` method.
pub fn from_args() -> Self {
<Self as StructOpt>::from_args()
}
}
mod commands;
pub use commands::Command;
fn main(){
match Command::from_args() {
Command::Init(cmd) => {
println!("{:?}", cmd.execute())
},
}
}
impl InitCmd {
/// Run the command
pub fn execute(&self) -> Result<(), Error> {
Ok(())
}
}