agave_validator/commands/
mod.rs1pub mod authorized_voter;
2pub mod blockstore;
3pub mod contact_info;
4pub mod exit;
5pub mod manage_block_production;
6pub mod monitor;
7pub mod plugin;
8pub mod repair_shred_from_peer;
9pub mod repair_whitelist;
10pub mod run;
11pub mod set_identity;
12pub mod set_log_filter;
13pub mod set_public_address;
14pub mod staked_nodes_overrides;
15pub mod wait_for_restart_window;
16
17use thiserror::Error;
18
19#[derive(Error, Debug)]
20pub enum Error {
21 #[error("admin rpc error: {0}")]
22 AdminRpc(#[from] jsonrpc_core_client::RpcError),
23
24 #[error(transparent)]
25 Clap(#[from] clap::Error),
26
27 #[error(transparent)]
28 Dynamic(#[from] Box<dyn std::error::Error>),
29
30 #[error(transparent)]
31 Io(#[from] std::io::Error),
32
33 #[error(transparent)]
34 TryFromInt(#[from] std::num::TryFromIntError),
35}
36pub type Result<T> = std::result::Result<T, Error>;
37
38pub trait FromClapArgMatches {
39 fn from_clap_arg_match(matches: &clap::ArgMatches) -> Result<Self>
40 where
41 Self: Sized;
42}
43
44#[cfg(test)]
45pub mod tests {
46 use std::fmt::Debug;
47
48 pub fn verify_args_struct_by_command<T>(app: clap::App, vec: Vec<&str>, expected_arg: T)
49 where
50 T: crate::commands::FromClapArgMatches + PartialEq + Debug,
51 {
52 let matches = app.get_matches_from(vec);
53 let result = T::from_clap_arg_match(&matches);
54 pretty_assertions::assert_eq!(result.unwrap(), expected_arg);
55 }
56
57 pub fn verify_args_struct_by_command_is_error<T>(app: clap::App, vec: Vec<&str>)
58 where
59 T: crate::commands::FromClapArgMatches + PartialEq + Debug,
60 {
61 let matches = app.get_matches_from_safe(vec);
62 assert!(matches.is_err());
63 }
64}