mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 14:28:37 +00:00
Change DB Manager Clap usage to derive (#5898)
* implement clap derive for the db manager * tweak some clap configs * make cli local * add global to help flag * fmt * Merge branch 'unstable' of https://github.com/sigp/lighthouse into HEAD * merge * add enum constraints to flag
This commit is contained in:
9
lighthouse/src/cli.rs
Normal file
9
lighthouse/src/cli.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use clap::Parser;
|
||||
use database_manager::cli::DatabaseManager;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Parser, Clone, Deserialize, Serialize, Debug)]
|
||||
pub enum LighthouseSubcommands {
|
||||
#[clap(name = "database_manager")]
|
||||
DatabaseManager(DatabaseManager),
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
mod cli;
|
||||
mod metrics;
|
||||
|
||||
use beacon_node::ProductionBeaconNode;
|
||||
use clap::FromArgMatches;
|
||||
use clap::Subcommand;
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use clap_utils::{
|
||||
flags::DISABLE_MALLOC_TUNING_FLAG, get_color_style, get_eth2_network_config, FLAG_HEADER,
|
||||
};
|
||||
use cli::LighthouseSubcommands;
|
||||
use directory::{parse_path_or_default, DEFAULT_BEACON_NODE_DIR, DEFAULT_VALIDATOR_DIR};
|
||||
use environment::{EnvironmentBuilder, LoggerConfig};
|
||||
use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK, HARDCODED_NET_NAMES};
|
||||
@@ -87,7 +91,7 @@ fn main() {
|
||||
}
|
||||
|
||||
// Parse the CLI parameters.
|
||||
let matches = Command::new("Lighthouse")
|
||||
let cli = Command::new("Lighthouse")
|
||||
.version(SHORT_VERSION.as_str())
|
||||
.author("Sigma Prime <contact@sigmaprime.io>")
|
||||
.styles(get_color_style())
|
||||
@@ -409,9 +413,11 @@ fn main() {
|
||||
.subcommand(boot_node::cli_app())
|
||||
.subcommand(validator_client::cli_app())
|
||||
.subcommand(account_manager::cli_app())
|
||||
.subcommand(database_manager::cli_app())
|
||||
.subcommand(validator_manager::cli_app())
|
||||
.get_matches();
|
||||
.subcommand(validator_manager::cli_app());
|
||||
|
||||
let cli = LighthouseSubcommands::augment_subcommands(cli);
|
||||
|
||||
let matches = cli.get_matches();
|
||||
|
||||
// Configure the allocator early in the process, before it has the chance to use the default values for
|
||||
// anything important.
|
||||
@@ -676,14 +682,13 @@ fn run<E: EthSpec>(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(sub_matches) = matches.subcommand_matches(database_manager::CMD) {
|
||||
if let Ok(LighthouseSubcommands::DatabaseManager(db_manager_config)) =
|
||||
LighthouseSubcommands::from_arg_matches(matches)
|
||||
{
|
||||
info!(log, "Running database manager for {} network", network_name);
|
||||
// Pass the entire `environment` to the database manager so it can run blocking operations.
|
||||
database_manager::run(sub_matches, environment)?;
|
||||
|
||||
// Exit as soon as database manager returns control.
|
||||
database_manager::run(matches, &db_manager_config, environment)?;
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
info!(log, "Lighthouse started"; "version" => VERSION);
|
||||
info!(
|
||||
|
||||
Reference in New Issue
Block a user