use anyhow::Result;
use env_logger::Env;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug)]
struct CustomError(String);
#[derive(Debug, StructOpt)]
struct Cli {
#[structopt(subcommand)]
cmd: Command,
}
#[derive(StructOpt, Debug)]
enum Command {
Gen {
#[structopt(short, long, default_value = ".", parse(from_os_str))]
target: PathBuf,
},
GenPass {
#[structopt(short, long, default_value = "16")]
length: u8,
},
Apply {
#[structopt(short, long, parse(from_os_str))]
file: PathBuf,
#[structopt(short, long)]
dryrun: bool,
#[structopt(short, long)]
conn: Option<String>,
},
}
fn main() -> Result<()> {
let env = Env::new().default_filter_or("info");
env_logger::init_from_env(env);
match Cli::from_args().cmd {
Command::Gen { target } => {
grant::gen::gen(&target);
}
Command::GenPass { length } => {
grant::gen::gen_password(length);
}
Command::Apply { file, dryrun, conn } => {
grant::apply::apply(&file, dryrun, conn);
}
}
Ok(())
}