Skip to main content

solana_clap_utils/
lib.rs

1#![cfg(feature = "agave-unstable-api")]
2use thiserror::Error;
3
4pub struct ArgConstant<'a> {
5    pub long: &'a str,
6    pub name: &'a str,
7    pub help: &'a str,
8}
9
10/// Error type for forwarding Errors out of `main()` of a `clap` app
11/// and still using the `Display` formatter
12#[derive(Error)]
13#[error("{0}")]
14pub struct DisplayError(Box<dyn std::error::Error>);
15impl DisplayError {
16    pub fn new_as_boxed(inner: Box<dyn std::error::Error>) -> Box<Self> {
17        DisplayError(inner).into()
18    }
19}
20
21impl std::fmt::Debug for DisplayError {
22    fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
23        write!(fmt, "{}", self.0)
24    }
25}
26
27pub fn hidden_unless_forced() -> bool {
28    std::env::var("SOLANA_NO_HIDDEN_CLI_ARGS").is_err()
29}
30
31pub mod compute_budget;
32pub mod fee_payer;
33pub mod input_parsers;
34pub mod input_validators;
35pub mod keypair;
36pub mod memo;
37pub mod nonce;
38pub mod offline;