-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BasicClient to ParsecToolApp #35
Conversation
src/main.rs
Outdated
matches.init_client().map_err(|e| { | ||
err!("{:?}", e); | ||
std::io::Error::new(std::io::ErrorKind::Other, "Spinning up BasicClient failed.") | ||
})?; | ||
matches.subcommand.run(&matches).map_err(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's very good to spin up the BasicClient before but couldn't it be cleaner if we do it directly in the main
function and pass the reference to the run
method? It seems cleaner than having it in the structopt structure, even though we can skip it. That way we keep both things separate (CLI and client)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that works for me - we can pass the whole client like that, not just a reference, since we only run one subcommand anyway. I'll update
This commit changes the Subcommand trait to accept a BasicClient when the command is run. The client can then be freely used during the subcommand processing. Signed-off-by: Ionut Mihalcea <[email protected]>
5f33673
to
f1522d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
use structopt::StructOpt; | ||
|
||
fn main() -> std::io::Result<()> { | ||
env_logger::init(); | ||
|
||
let matches = cli::ParsecToolApp::from_args(); | ||
matches.subcommand.run(&matches).map_err(|e| { | ||
let client = BasicClient::new(matches.app_name.clone()).map_err(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 looks nice!
This commit adds an instance of BasicClient to the ParsecToolApp so that
all subcommands can simply use this one instead of spinning up their
own.
Signed-off-by: Ionut Mihalcea [email protected]