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