1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pub(crate) use crate::commands::run;
use clap::{Parser, Subcommand};
use fuel_indexer_lib::config::IndexerArgs;

#[derive(Parser, Debug)]
#[clap(
    name = "fuel-indexer",
    about = "Fuel Indexer service",
    version,
    rename_all = "kebab-case"
)]

pub struct Opt {
    #[clap(subcommand)]
    command: Indexer,
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug, Subcommand)]
pub enum Indexer {
    Run(IndexerArgs),
}

pub async fn run_cli() -> anyhow::Result<()> {
    let opt = Opt::try_parse();
    match opt {
        Ok(opt) => match opt.command {
            Indexer::Run(args) => run::exec(args).await,
        },
        Err(e) => e.exit(),
    }
}