sui_cluster_test/
config.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use clap::*;
5use regex::Regex;
6use std::path::PathBuf;
7
8#[derive(Parser, Clone, ValueEnum, Debug)]
9pub enum Env {
10    Devnet,
11    Staging,
12    Ci,
13    CiNomad,
14    Testnet,
15    CustomRemote,
16    NewLocal,
17}
18
19#[derive(derive_more::Debug, Parser)]
20#[clap(name = "", rename_all = "kebab-case")]
21pub struct ClusterTestOpt {
22    #[clap(value_enum)]
23    pub env: Env,
24    #[clap(long)]
25    pub faucet_address: Option<String>,
26    #[clap(long)]
27    pub fullnode_address: Option<String>,
28    #[clap(long)]
29    pub epoch_duration_ms: Option<u64>,
30    /// URL for the indexer RPC server
31    #[clap(long)]
32    pub indexer_address: Option<String>,
33    /// URL for the Indexer Postgres DB
34    #[clap(long)]
35    #[debug("{}", match pg_address {
36        None => "None".into(),
37        Some(val) => Regex::new(r":.*@")
38            .unwrap()
39            .replace_all(val.as_str(), ":*****@"),
40    })]
41    pub pg_address: Option<String>,
42    #[clap(long)]
43    pub config_dir: Option<PathBuf>,
44    /// URL for the indexer RPC server
45    #[clap(long)]
46    pub graphql_address: Option<String>,
47    /// Indicate that an indexer and graphql service should be started
48    ///
49    /// Only used with a local cluster
50    #[clap(long)]
51    pub with_indexer_and_graphql: bool,
52}
53
54impl ClusterTestOpt {
55    pub fn new_local() -> Self {
56        Self {
57            env: Env::NewLocal,
58            faucet_address: None,
59            fullnode_address: None,
60            epoch_duration_ms: None,
61            indexer_address: None,
62            pg_address: None,
63            config_dir: None,
64            graphql_address: None,
65            with_indexer_and_graphql: false,
66        }
67    }
68}