upgrade clap to v4.5 (#5273)

* upgrade clap to v4.5

* cli fixes

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli

* value parser for mnemonic

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli

* merge unstable

* default --format val

* fix eth sim

* fix eth sim

* merge conflicts

* resolve beta compiler issue

* add num args, version

* add custom flag parser, make rate limiter flags clap friendly

* remove unneeded check

* fmt

* update

* alphabetic order

* resolve merge conflict

* fix test

* resolve conflicts

* fix test

* revert removed if statement

* fmt got me again

* fix broken flag

* make cli

* make cli

* update

* remove -e files

* update

* cli help updates

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli

* cli help updates

* md files

* merge conflict

* merge conflicts

* md

* help text, text width, and a few flag fixes

* fmt

* merge

* revert

* revert

* resolve merge conflicts

* merge conflicts

* revert simulator changes

* require at least one arg

* fix eth sim cli

* resolve merge conflicts

* book changes

* md changes

* cli check

* cli check

* retry cli check

* retry cli check

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli

* cli

* Merge remote-tracking branch 'origin/unstable' into upgrade-clap-cli

* Update CLI docs for Goerli removal

* Fix cargo lock
This commit is contained in:
Eitan Seri-Levi
2024-05-28 07:46:39 +02:00
committed by GitHub
parent 6a7305a487
commit df983a83e1
61 changed files with 4036 additions and 2868 deletions

View File

@@ -1,5 +1,5 @@
use clap::App;
use clap::ArgMatches;
use clap::{Arg, ArgAction, ArgMatches, Command};
use clap_utils::{get_color_style, FLAG_HEADER};
use common::write_to_json_file;
use environment::Environment;
use serde::Serialize;
@@ -38,17 +38,28 @@ impl DumpConfig {
}
}
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
App::new(CMD)
.visible_aliases(&["vm", "validator-manager", CMD])
pub fn cli_app() -> Command {
Command::new(CMD)
.visible_aliases(["vm", "validator-manager", CMD])
.display_order(0)
.styles(get_color_style())
.about("Utilities for managing a Lighthouse validator client via the HTTP API.")
.arg(
Arg::new("help")
.long("help")
.short('h')
.help("Prints help information")
.action(ArgAction::HelpLong)
.display_order(0)
.help_heading(FLAG_HEADER),
)
.subcommand(create_validators::cli_app())
.subcommand(import_validators::cli_app())
.subcommand(move_validators::cli_app())
}
/// Run the account manager, returning an error if the operation did not succeed.
pub fn run<'a, E: EthSpec>(matches: &'a ArgMatches<'a>, env: Environment<E>) -> Result<(), String> {
pub fn run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> Result<(), String> {
let context = env.core_context();
let spec = context.eth2_config.spec;
let dump_config = clap_utils::parse_optional(matches, DUMP_CONFIGS_FLAG)?
@@ -63,20 +74,20 @@ pub fn run<'a, E: EthSpec>(matches: &'a ArgMatches<'a>, env: Environment<E>) ->
.block_on_dangerous(
async {
match matches.subcommand() {
(create_validators::CMD, Some(matches)) => {
Some((create_validators::CMD, matches)) => {
create_validators::cli_run::<E>(matches, &spec, dump_config).await
}
(import_validators::CMD, Some(matches)) => {
Some((import_validators::CMD, matches)) => {
import_validators::cli_run(matches, dump_config).await
}
(move_validators::CMD, Some(matches)) => {
Some((move_validators::CMD, matches)) => {
move_validators::cli_run(matches, dump_config).await
}
("", _) => Err("No command supplied. See --help.".to_string()),
(unknown, _) => Err(format!(
Some((unknown, _)) => Err(format!(
"{} is not a valid {} command. See --help.",
unknown, CMD
)),
_ => Err("No command supplied. See --help.".to_string()),
}
},
"validator_manager",