solana_clap_utils/
lib.rs

1#![cfg_attr(
2    not(feature = "agave-unstable-api"),
3    deprecated(
4        since = "3.1.0",
5        note = "This crate has been marked for formal inclusion in the Agave Unstable API. From \
6                v4.0.0 onward, the `agave-unstable-api` crate feature must be specified to \
7                acknowledge use of an interface that may break without warning."
8    )
9)]
10use thiserror::Error;
11
12pub struct ArgConstant<'a> {
13    pub long: &'a str,
14    pub name: &'a str,
15    pub help: &'a str,
16}
17
18/// Error type for forwarding Errors out of `main()` of a `clap` app
19/// and still using the `Display` formatter
20#[derive(Error)]
21#[error("{0}")]
22pub struct DisplayError(Box<dyn std::error::Error>);
23impl DisplayError {
24    pub fn new_as_boxed(inner: Box<dyn std::error::Error>) -> Box<Self> {
25        DisplayError(inner).into()
26    }
27}
28
29impl std::fmt::Debug for DisplayError {
30    fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
31        write!(fmt, "{}", self.0)
32    }
33}
34
35pub fn hidden_unless_forced() -> bool {
36    std::env::var("SOLANA_NO_HIDDEN_CLI_ARGS").is_err()
37}
38
39pub mod compute_budget;
40pub mod compute_unit_price;
41pub mod fee_payer;
42pub mod input_parsers;
43pub mod input_validators;
44pub mod keypair;
45pub mod memo;
46pub mod nonce;
47pub mod offline;