forest/tool/subcommands/
mod.rs

1// Copyright 2019-2025 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4mod api_cmd;
5pub(crate) mod archive_cmd;
6mod backup_cmd;
7mod benchmark_cmd;
8mod car_cmd;
9mod db_cmd;
10mod fetch_params_cmd;
11mod index_cmd;
12mod net_cmd;
13mod shed_cmd;
14mod snapshot_cmd;
15mod state_compute_cmd;
16mod state_migration_cmd;
17
18use crate::cli_shared::cli::*;
19use crate::cli_shared::cli::{CompletionCommand, HELP_MESSAGE};
20use crate::utils::version::FOREST_VERSION_STRING;
21use clap::Parser;
22
23/// Command-line options for the `forest-tool` binary
24#[derive(Parser)]
25#[command(name = env!("CARGO_PKG_NAME"), bin_name = "forest-tool", author = env!("CARGO_PKG_AUTHORS"), version = FOREST_VERSION_STRING.as_str(), about = env!("CARGO_PKG_DESCRIPTION")
26)]
27#[command(help_template(HELP_MESSAGE))]
28pub struct Cli {
29    #[command(subcommand)]
30    pub cmd: Subcommand,
31}
32
33/// forest-tool sub-commands
34#[derive(clap::Subcommand)]
35#[allow(clippy::large_enum_variant)]
36pub enum Subcommand {
37    /// Create and restore backups
38    #[command(subcommand)]
39    Backup(backup_cmd::BackupCommands),
40
41    /// Benchmark various Forest subsystems
42    #[command(subcommand)]
43    Benchmark(benchmark_cmd::BenchmarkCommands),
44
45    /// State migration tools
46    #[command(subcommand)]
47    StateMigration(state_migration_cmd::StateMigrationCommands),
48
49    /// Manage snapshots
50    #[command(subcommand)]
51    Snapshot(snapshot_cmd::SnapshotCommands),
52
53    /// Download parameters for generating and verifying proofs for given size
54    #[command(name = "fetch-params")]
55    Fetch(fetch_params_cmd::FetchCommands),
56
57    /// Manage archives
58    #[command(subcommand)]
59    Archive(archive_cmd::ArchiveCommands),
60
61    /// Database management
62    #[command(subcommand)]
63    DB(db_cmd::DBCommands),
64
65    /// Index database management
66    #[command(subcommand)]
67    Index(index_cmd::IndexCommands),
68
69    /// Utilities for manipulating CAR files
70    #[command(subcommand)]
71    Car(car_cmd::CarCommands),
72
73    /// API tooling
74    #[command(subcommand)]
75    Api(api_cmd::ApiCommands),
76
77    /// Network utilities
78    #[command(subcommand)]
79    Net(net_cmd::NetCommands),
80
81    /// Miscellaneous, semver-exempt commands for developer use.
82    #[command(subcommand)]
83    Shed(shed_cmd::ShedCommands),
84
85    #[command(subcommand)]
86    State(state_compute_cmd::StateCommand),
87
88    Completion(CompletionCommand),
89}