This commit is contained in:
Aiden McClelland
2021-07-01 10:51:22 -06:00
parent dcd02c03a0
commit 7bbbb5463e
19 changed files with 258 additions and 49 deletions

View File

@@ -4,13 +4,35 @@ use embassy::Error;
use rpc_toolkit::run_cli;
fn inner_main() -> Result<(), Error> {
simple_logging::log_to_stderr(log::LevelFilter::Info);
run_cli!(
embassy::main_api,
app => app.name("Embassy CLI")
app => app
.name("Embassy CLI")
.arg(
clap::Arg::with_name("config")
.short("c")
.long("config")
.takes_value(true),
)
.arg(
clap::Arg::with_name("verbosity")
.short("v")
.multiple(true)
.takes_value(false),
)
.arg(Arg::with_name("host").long("host").short("h").takes_value(true))
.arg(Arg::with_name("port").long("port").short("p").takes_value(true)),
matches => EitherContext::Cli(CliContext::init(matches)?),
matches => {
simple_logging::log_to_stderr(match matches.occurrences_of("verbosity") {
0 => log::LevelFilter::Off,
1 => log::LevelFilter::Error,
2 => log::LevelFilter::Warn,
3 => log::LevelFilter::Info,
4 => log::LevelFilter::Debug,
_ => log::LevelFilter::Trace,
});
EitherContext::Cli(CliContext::init(matches)?)
},
|code| if code < 0 { 1 } else { code }
)
}

View File

@@ -4,11 +4,33 @@ use embassy::Error;
use rpc_toolkit::run_cli;
fn inner_main() -> Result<(), Error> {
simple_logging::log_to_stderr(log::LevelFilter::Info);
run_cli!(
embassy::portable_api,
app => app.name("Embassy SDK"),
matches => EitherContext::Cli(CliContext::init(matches)?),
app => app
.name("Embassy SDK")
.arg(
clap::Arg::with_name("config")
.short("c")
.long("config")
.takes_value(true),
)
.arg(
clap::Arg::with_name("verbosity")
.short("v")
.multiple(true)
.takes_value(false),
),
matches => {
simple_logging::log_to_stderr(match matches.occurrences_of("verbosity") {
0 => log::LevelFilter::Off,
1 => log::LevelFilter::Error,
2 => log::LevelFilter::Warn,
3 => log::LevelFilter::Info,
4 => log::LevelFilter::Debug,
_ => log::LevelFilter::Trace,
});
EitherContext::Cli(CliContext::init(matches)?)
},
|code| if code < 0 { 1 } else { code }
)
}