Allow --validator-dir to be specified after subcommands (#8329)

#3768


  Made the --validator-dir flag global so that it can be specified in any order


Co-Authored-By: Mike Jerred <mjerred.work@gmail.com>

Co-Authored-By: chonghe <44791194+chong-he@users.noreply.github.com>
This commit is contained in:
Mike Jerred
2026-04-09 06:36:45 +01:00
committed by GitHub
parent 2749e18d0e
commit 815aad3731
2 changed files with 10 additions and 9 deletions

View File

@@ -28,6 +28,7 @@ pub fn cli_app() -> Command {
"The path to search for validator directories. \ "The path to search for validator directories. \
Defaults to ~/.lighthouse/{network}/validators", Defaults to ~/.lighthouse/{network}/validators",
) )
.global(true)
.action(ArgAction::Set) .action(ArgAction::Set)
.conflicts_with("datadir"), .conflicts_with("datadir"),
) )

View File

@@ -248,9 +248,9 @@ impl TestValidator {
store_withdrawal_key: bool, store_withdrawal_key: bool,
) -> Result<Vec<String>, String> { ) -> Result<Vec<String>, String> {
let mut cmd = validator_cmd(); let mut cmd = validator_cmd();
cmd.arg(format!("--{}", VALIDATOR_DIR_FLAG)) cmd.arg(CREATE_CMD)
.arg(format!("--{}", VALIDATOR_DIR_FLAG))
.arg(self.validator_dir.clone().into_os_string()) .arg(self.validator_dir.clone().into_os_string())
.arg(CREATE_CMD)
.arg(format!("--{}", WALLETS_DIR_FLAG)) .arg(format!("--{}", WALLETS_DIR_FLAG))
.arg(self.wallet.base_dir().into_os_string()) .arg(self.wallet.base_dir().into_os_string())
.arg(format!("--{}", WALLET_NAME_FLAG)) .arg(format!("--{}", WALLET_NAME_FLAG))
@@ -427,9 +427,9 @@ fn validator_import_launchpad() {
File::create(src_dir.path().join(NOT_KEYSTORE_NAME)).unwrap(); File::create(src_dir.path().join(NOT_KEYSTORE_NAME)).unwrap();
let mut child = validator_cmd() let mut child = validator_cmd()
.arg(IMPORT_CMD)
.arg(format!("--{}", VALIDATOR_DIR_FLAG)) .arg(format!("--{}", VALIDATOR_DIR_FLAG))
.arg(dst_dir.path().as_os_str()) .arg(dst_dir.path().as_os_str())
.arg(IMPORT_CMD)
.arg(format!("--{}", STDIN_INPUTS_FLAG)) // Using tty does not work well with tests. .arg(format!("--{}", STDIN_INPUTS_FLAG)) // Using tty does not work well with tests.
.arg(format!("--{}", import::DIR_FLAG)) .arg(format!("--{}", import::DIR_FLAG))
.arg(src_dir.path().as_os_str()) .arg(src_dir.path().as_os_str())
@@ -479,10 +479,10 @@ fn validator_import_launchpad() {
// Disable all the validators in validator_definition. // Disable all the validators in validator_definition.
output_result( output_result(
validator_cmd() validator_cmd()
.arg(format!("--{}", VALIDATOR_DIR_FLAG))
.arg(dst_dir.path().as_os_str())
.arg(MODIFY_CMD) .arg(MODIFY_CMD)
.arg(DISABLE) .arg(DISABLE)
.arg(format!("--{}", VALIDATOR_DIR_FLAG))
.arg(dst_dir.path().as_os_str())
.arg(format!("--{}", ALL)), .arg(format!("--{}", ALL)),
) )
.unwrap(); .unwrap();
@@ -514,10 +514,10 @@ fn validator_import_launchpad() {
// Enable keystore validator again // Enable keystore validator again
output_result( output_result(
validator_cmd() validator_cmd()
.arg(format!("--{}", VALIDATOR_DIR_FLAG))
.arg(dst_dir.path().as_os_str())
.arg(MODIFY_CMD) .arg(MODIFY_CMD)
.arg(ENABLE) .arg(ENABLE)
.arg(format!("--{}", VALIDATOR_DIR_FLAG))
.arg(dst_dir.path().as_os_str())
.arg(format!("--{}", PUBKEY_FLAG)) .arg(format!("--{}", PUBKEY_FLAG))
.arg(format!("{}", keystore.public_key().unwrap())), .arg(format!("{}", keystore.public_key().unwrap())),
) )
@@ -560,9 +560,9 @@ fn validator_import_launchpad_no_password_then_add_password() {
let validator_import_key_cmd = || { let validator_import_key_cmd = || {
validator_cmd() validator_cmd()
.arg(IMPORT_CMD)
.arg(format!("--{}", VALIDATOR_DIR_FLAG)) .arg(format!("--{}", VALIDATOR_DIR_FLAG))
.arg(dst_dir.path().as_os_str()) .arg(dst_dir.path().as_os_str())
.arg(IMPORT_CMD)
.arg(format!("--{}", STDIN_INPUTS_FLAG)) // Using tty does not work well with tests. .arg(format!("--{}", STDIN_INPUTS_FLAG)) // Using tty does not work well with tests.
.arg(format!("--{}", import::DIR_FLAG)) .arg(format!("--{}", import::DIR_FLAG))
.arg(src_dir.path().as_os_str()) .arg(src_dir.path().as_os_str())
@@ -700,9 +700,9 @@ fn validator_import_launchpad_password_file() {
.unwrap(); .unwrap();
let mut child = validator_cmd() let mut child = validator_cmd()
.arg(IMPORT_CMD)
.arg(format!("--{}", VALIDATOR_DIR_FLAG)) .arg(format!("--{}", VALIDATOR_DIR_FLAG))
.arg(dst_dir.path().as_os_str()) .arg(dst_dir.path().as_os_str())
.arg(IMPORT_CMD)
.arg(format!("--{}", import::DIR_FLAG)) .arg(format!("--{}", import::DIR_FLAG))
.arg(src_dir.path().as_os_str()) .arg(src_dir.path().as_os_str())
.arg(format!("--{}", import::REUSE_PASSWORD_FLAG)) .arg(format!("--{}", import::REUSE_PASSWORD_FLAG))