Add a `connect` command for testing.

This commit is contained in:
Henry de Valence 2019-09-11 22:30:32 -07:00
parent f2357deaff
commit f63651c7dc
2 changed files with 39 additions and 1 deletions

View File

@ -10,10 +10,11 @@
//! See the `impl Configurable` below for how to specify the path to the
//! application's configuration file.
mod connect;
mod start;
mod version;
use self::{start::StartCmd, version::VersionCmd};
use self::{connect::ConnectCmd, start::StartCmd, version::VersionCmd};
use crate::config::ZebradConfig;
use abscissa_core::{
config::Override, Command, Configurable, FrameworkError, Help, Options, Runnable,
@ -37,6 +38,10 @@ pub enum ZebradCmd {
/// The `version` subcommand
#[options(help = "display version information")]
Version(VersionCmd),
/// The `connect` subcommand
#[options(help = "testing stub for dumping network messages")]
Connect(ConnectCmd),
}
/// This trait allows you to define how application configuration is loaded.

View File

@ -0,0 +1,33 @@
//! `connect` subcommand - test stub for talking to zcashd
use crate::prelude::*;
use abscissa_core::{Command, Options, Runnable};
/// `connect` subcommand
#[derive(Command, Debug, Options)]
pub struct ConnectCmd {
/// The address of the node to connect to.
#[options(
help = "The address of the node to connect to.",
default = "127.0.0.1:8233"
)]
addr: std::net::SocketAddr,
}
impl Runnable for ConnectCmd {
/// Start the application.
fn run(&self) {
info!(connect.addr = ?self.addr);
use crate::components::tokio::TokioComponent;
app_reader()
.state()
.components
.get_downcast_ref::<TokioComponent>()
.expect("TokioComponent should be available")
.rt
.block_on(tokio::future::pending::<()>());
}
}