sui_indexer_alt/
args.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use std::path::PathBuf;
5
6use crate::IndexerArgs;
7#[cfg(feature = "benchmark")]
8use crate::benchmark::BenchmarkArgs;
9use clap::Subcommand;
10use sui_indexer_alt_framework::{ingestion::ClientArgs, postgres::DbArgs};
11use sui_indexer_alt_metrics::MetricsArgs;
12use url::Url;
13
14#[derive(clap::Parser, Debug, Clone)]
15pub struct Args {
16    #[command(subcommand)]
17    pub command: Command,
18}
19
20#[allow(clippy::large_enum_variant)]
21#[derive(Subcommand, Clone, Debug)]
22pub enum Command {
23    /// Run the indexer.
24    Indexer {
25        /// The URL of the database to connect to.
26        #[clap(
27            long,
28            default_value = "postgres://postgres:postgrespw@localhost:5432/sui_indexer_alt"
29        )]
30        database_url: Url,
31
32        #[command(flatten)]
33        db_args: DbArgs,
34
35        #[command(flatten)]
36        client_args: ClientArgs,
37
38        #[command(flatten)]
39        indexer_args: IndexerArgs,
40
41        #[command(flatten)]
42        metrics_args: MetricsArgs,
43
44        /// Path to the indexer's configuration TOML file.
45        #[arg(long)]
46        config: PathBuf,
47    },
48
49    /// Output the contents of the default configuration to STDOUT.
50    GenerateConfig,
51
52    /// Combine the configuration held across multiple files into one and output it to STDOUT. When
53    /// two configurations set the same field, the last write wins.
54    MergeConfigs {
55        /// Path to a TOML file to be merged
56        #[arg(long, required = true, action = clap::ArgAction::Append)]
57        config: Vec<PathBuf>,
58    },
59
60    /// Wipe the database of its contents
61    ResetDatabase {
62        /// The URL of the database to connect to.
63        #[clap(
64            long,
65            default_value = "postgres://postgres:postgrespw@localhost:5432/sui_indexer_alt"
66        )]
67        database_url: Url,
68
69        #[command(flatten)]
70        db_args: DbArgs,
71
72        /// If true, only drop all tables but do not run the migrations.
73        /// That is, no tables will exist in the DB after the reset.
74        #[clap(long, default_value_t = false)]
75        skip_migrations: bool,
76    },
77
78    /// Run the benchmark. It will load ingestion data from the given path and run the pipelines.
79    /// The first and last checkpoint will be determined automatically based on the ingestion data.
80    /// Note that the indexer will not be bootstrapped from genesis, and hence will
81    /// skip any pipelines that rely on genesis data.
82    #[cfg(feature = "benchmark")]
83    Benchmark {
84        /// The URL of the database to connect to.
85        #[clap(
86            long,
87            default_value = "postgres://postgres:postgrespw@localhost:5432/sui_indexer_alt"
88        )]
89        database_url: Url,
90
91        #[command(flatten)]
92        db_args: DbArgs,
93
94        #[command(flatten)]
95        benchmark_args: BenchmarkArgs,
96
97        /// Path to the indexer's configuration TOML file.
98        #[arg(long)]
99        config: PathBuf,
100    },
101}