Add aliases for validator-dir flags (#3034)

## Issue Addressed

#3020

## Proposed Changes

- Alias the `validators-dir` arg to `validator-dir` in the `validator_client` subcommand.
- Alias the `validator-dir` arg to `validators-dir` in the `account_manager validator` subcommand.
- Add test for the validator_client alias.
This commit is contained in:
Mac L 2022-02-22 03:09:02 +00:00
parent 5a0b049049
commit 696de58141
4 changed files with 17 additions and 1 deletions

View File

@ -10,6 +10,7 @@ use types::EthSpec;
pub const CMD: &str = "account_manager"; pub const CMD: &str = "account_manager";
pub const SECRETS_DIR_FLAG: &str = "secrets-dir"; pub const SECRETS_DIR_FLAG: &str = "secrets-dir";
pub const VALIDATOR_DIR_FLAG: &str = "validator-dir"; pub const VALIDATOR_DIR_FLAG: &str = "validator-dir";
pub const VALIDATOR_DIR_FLAG_ALIAS: &str = "validators-dir";
pub const WALLETS_DIR_FLAG: &str = "wallets-dir"; pub const WALLETS_DIR_FLAG: &str = "wallets-dir";
pub fn cli_app<'a, 'b>() -> App<'a, 'b> { pub fn cli_app<'a, 'b>() -> App<'a, 'b> {

View File

@ -6,7 +6,7 @@ pub mod modify;
pub mod recover; pub mod recover;
pub mod slashing_protection; pub mod slashing_protection;
use crate::VALIDATOR_DIR_FLAG; use crate::{VALIDATOR_DIR_FLAG, VALIDATOR_DIR_FLAG_ALIAS};
use clap::{App, Arg, ArgMatches}; use clap::{App, Arg, ArgMatches};
use directory::{parse_path_or_default_with_flag, DEFAULT_VALIDATOR_DIR}; use directory::{parse_path_or_default_with_flag, DEFAULT_VALIDATOR_DIR};
use environment::Environment; use environment::Environment;
@ -21,6 +21,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.arg( .arg(
Arg::with_name(VALIDATOR_DIR_FLAG) Arg::with_name(VALIDATOR_DIR_FLAG)
.long(VALIDATOR_DIR_FLAG) .long(VALIDATOR_DIR_FLAG)
.alias(VALIDATOR_DIR_FLAG_ALIAS)
.value_name("VALIDATOR_DIRECTORY") .value_name("VALIDATOR_DIRECTORY")
.help( .help(
"The path to search for validator directories. \ "The path to search for validator directories. \

View File

@ -66,6 +66,19 @@ fn validators_and_secrets_dir_flags() {
}); });
} }
#[test]
fn validators_dir_alias_flags() {
let dir = TempDir::new().expect("Unable to create temporary directory");
CommandLineTest::new()
.flag("validator-dir", dir.path().join("validators").to_str())
.flag("secrets-dir", dir.path().join("secrets").to_str())
.run_with_no_datadir()
.with_config(|config| {
assert_eq!(config.validator_dir, dir.path().join("validators"));
assert_eq!(config.secrets_dir, dir.path().join("secrets"));
});
}
#[test] #[test]
fn beacon_nodes_flag() { fn beacon_nodes_flag() {
CommandLineTest::new() CommandLineTest::new()

View File

@ -38,6 +38,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.arg( .arg(
Arg::with_name("validators-dir") Arg::with_name("validators-dir")
.long("validators-dir") .long("validators-dir")
.alias("validator-dir")
.value_name("VALIDATORS_DIR") .value_name("VALIDATORS_DIR")
.help( .help(
"The directory which contains the validator keystores, deposit data for \ "The directory which contains the validator keystores, deposit data for \