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:
Eitan Seri-Levi
2024-07-12 07:52:09 +01:00
committed by GitHub
parent 7697c127f1
commit b7b5dd7ec9
9 changed files with 349 additions and 287 deletions

View File

@@ -402,7 +402,10 @@ pub fn get_config<E: EthSpec>(
client_config.blobs_db_path = Some(PathBuf::from(blobs_db_dir));
}
let (sprp, sprp_explicit) = get_slots_per_restore_point::<E>(cli_args)?;
let (sprp, sprp_explicit) = get_slots_per_restore_point::<E>(clap_utils::parse_optional(
cli_args,
"slots-per-restore-point",
)?)?;
client_config.store.slots_per_restore_point = sprp;
client_config.store.slots_per_restore_point_set_explicitly = sprp_explicit;
@@ -1476,11 +1479,9 @@ pub fn get_data_dir(cli_args: &ArgMatches) -> PathBuf {
///
/// Return `(sprp, set_explicitly)` where `set_explicitly` is `true` if the user provided the value.
pub fn get_slots_per_restore_point<E: EthSpec>(
cli_args: &ArgMatches,
slots_per_restore_point: Option<u64>,
) -> Result<(u64, bool), String> {
if let Some(slots_per_restore_point) =
clap_utils::parse_optional(cli_args, "slots-per-restore-point")?
{
if let Some(slots_per_restore_point) = slots_per_restore_point {
Ok((slots_per_restore_point, true))
} else {
let default = std::cmp::min(