cli

Command-line interface for Radroots
git clone https://radroots.dev/git/cli.git
Log | Files | Refs | README | LICENSE

mod.rs (1707B)


      1 pub mod account;
      2 pub mod config;
      3 pub mod direct_relay;
      4 pub mod farm;
      5 pub mod farm_config;
      6 pub mod find;
      7 pub mod hyf;
      8 pub mod listing;
      9 pub mod local_events;
     10 pub mod logging;
     11 pub mod network;
     12 pub mod order;
     13 pub mod paths;
     14 pub mod provider;
     15 pub mod sdk;
     16 pub mod signer;
     17 pub mod store;
     18 pub mod sync;
     19 pub mod validation_receipt;
     20 
     21 use std::process::ExitCode;
     22 
     23 #[derive(Debug, thiserror::Error)]
     24 pub enum RuntimeError {
     25     #[error("{0}")]
     26     Config(String),
     27     #[error("{0}")]
     28     Account(#[from] account::AccountRuntimeFailure),
     29     #[error("failed to initialize logging: {0}")]
     30     Logging(#[from] radroots_log::Error),
     31     #[error("accounts error: {0}")]
     32     Accounts(#[from] radroots_nostr_accounts::prelude::RadrootsNostrAccountsError),
     33     #[error("replica sql error: {0}")]
     34     Sql(#[from] radroots_replica_db::SqlError),
     35     #[error("replica sync error: {0}")]
     36     ReplicaSync(#[from] radroots_replica_sync::RadrootsReplicaEventsError),
     37     #[error("local events error: {0}")]
     38     LocalEvents(#[from] radroots_local_events::LocalEventsError),
     39     #[error("network error: {0}")]
     40     Network(String),
     41     #[error("failed to serialize json output: {0}")]
     42     Json(#[from] serde_json::Error),
     43     #[error("failed to write output: {0}")]
     44     Io(#[from] std::io::Error),
     45 }
     46 
     47 impl RuntimeError {
     48     pub fn exit_code(&self) -> ExitCode {
     49         match self {
     50             Self::Config(_) | Self::Account(_) => ExitCode::from(2),
     51             Self::Logging(_)
     52             | Self::Accounts(_)
     53             | Self::Sql(_)
     54             | Self::ReplicaSync(_)
     55             | Self::LocalEvents(_)
     56             | Self::Network(_)
     57             | Self::Json(_)
     58             | Self::Io(_) => ExitCode::from(1),
     59         }
     60     }
     61 }