use structopt::clap::AppSettings;
use structopt::StructOpt;
mod drain;
use drain::DrainCli;
mod claims;
use claims::ClaimsCli;
mod ctl;
use ctl::CtlCli;
mod generate;
use generate::NewCli;
mod keys;
use keys::KeysCli;
mod par;
use par::ParCli;
mod reg;
use reg::RegCli;
mod smithy;
use smithy::{GenerateCli, LintCli, ValidateCli};
mod call;
use call::CallCli;
mod util;
const ASCII: &str = "
_____ _ _ _____ _ _ _
/ ____| | | | / ____| | | | |
__ ____ _ ___ _ __ ___ | | | | ___ _ _ __| | | (___ | |__ ___| | |
\\ \\ /\\ / / _` / __| '_ ` _ \\| | | |/ _ \\| | | |/ _` | \\___ \\| '_ \\ / _ \\ | |
\\ V V / (_| \\__ \\ | | | | | |____| | (_) | |_| | (_| | ____) | | | | __/ | |
\\_/\\_/ \\__,_|___/_| |_| |_|\\_____|_|\\___/ \\__,_|\\__,_| |_____/|_| |_|\\___|_|_|
A single CLI to handle all of your wasmCloud tooling needs
";
#[derive(Debug, Clone, StructOpt)]
#[structopt(global_settings(&[AppSettings::ColoredHelp, AppSettings::VersionlessSubcommands, AppSettings::DisableHelpSubcommand]),
name = "wash",
about = ASCII)]
struct Cli {
#[structopt(flatten)]
command: CliCommand,
}
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, StructOpt)]
enum CliCommand {
#[structopt(name = "call")]
Call(CallCli),
#[structopt(name = "claims")]
Claims(Box<ClaimsCli>),
#[structopt(name = "ctl")]
Ctl(CtlCli),
#[structopt(name = "drain")]
Drain(DrainCli),
#[structopt(name = "gen")]
Gen(GenerateCli),
#[structopt(name = "keys", aliases = &["key"])]
Keys(KeysCli),
#[structopt(name = "new")]
New(NewCli),
#[structopt(name = "par")]
Par(ParCli),
#[structopt(name = "reg")]
Reg(RegCli),
#[structopt(name = "lint")]
Lint(LintCli),
#[structopt(name = "validate")]
Validate(ValidateCli),
}
#[tokio::main]
async fn main() {
if env_logger::try_init().is_err() {}
let cli = Cli::from_args();
let res = match cli.command {
CliCommand::Call(callcli) => call::handle_command(callcli.command()).await,
CliCommand::Claims(claimscli) => claims::handle_command(claimscli.command()).await,
CliCommand::Ctl(ctlcli) => ctl::handle_command(ctlcli.command()).await,
CliCommand::Drain(draincmd) => drain::handle_command(draincmd.command()),
CliCommand::Gen(generate_cli) => smithy::handle_gen_command(generate_cli),
CliCommand::Keys(keyscli) => keys::handle_command(keyscli.command()),
CliCommand::New(newcli) => generate::handle_command(newcli.command()),
CliCommand::Par(parcli) => par::handle_command(parcli.command()).await,
CliCommand::Reg(regcli) => reg::handle_command(regcli.command()).await,
CliCommand::Lint(lint_cli) => smithy::handle_lint_command(lint_cli).await,
CliCommand::Validate(validate_cli) => smithy::handle_validate_command(validate_cli).await,
};
std::process::exit(match res {
Ok(out) => {
println!("{}", out);
0
}
Err(e) => {
eprintln!("Error: {}", e);
1
}
})
}