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