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