Add a `connect` command for testing.
This commit is contained in:
parent
f2357deaff
commit
f63651c7dc
|
@ -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.
|
||||
|
|
|
@ -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::<()>());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue