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 ctx;
use ctx::CtxCli;
mod util;
const ASCII: &str = r#"
_____ _ _ _____ _ _ _
/ ____| | | | / ____| | | | |
__ ____ _ ___ _ __ ___ | | | | ___ _ _ __| | | (___ | |__ ___| | |
\ \ /\ / / _` / __| '_ ` _ \| | | |/ _ \| | | |/ _` | \___ \| '_ \ / _ \ | |
\ 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 = "ctx")]
Ctx(CtxCli),
#[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(call_cli) => call::handle_command(call_cli.command()).await,
CliCommand::Claims(claims_cli) => claims::handle_command(claims_cli.command()).await,
CliCommand::Ctl(ctl_cli) => ctl::handle_command(ctl_cli.command()).await,
CliCommand::Ctx(ctx_cli) => ctx::handle_command(ctx_cli.command()).await,
CliCommand::Drain(drain_cmd) => drain::handle_command(drain_cmd.command()),
CliCommand::Gen(generate_cli) => smithy::handle_gen_command(generate_cli),
CliCommand::Keys(keys_cli) => keys::handle_command(keys_cli.command()),
CliCommand::New(new_cli) => generate::handle_command(new_cli.command()),
CliCommand::Par(par_cli) => par::handle_command(par_cli.command()).await,
CliCommand::Reg(reg_cli) => reg::handle_command(reg_cli.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
}
})
}