Default --ledger arg to "ledger" for `solana-validator` and `solana-ledger-tool`

This commit is contained in:
Michael Vines 2021-03-11 11:14:54 -08:00
parent 1061d021c9
commit aa2b2d6b75
3 changed files with 16 additions and 6 deletions

View File

@ -221,7 +221,8 @@ impl BigTableSubCommand for App<'_, '_> {
self.subcommand( self.subcommand(
SubCommand::with_name("bigtable") SubCommand::with_name("bigtable")
.about("Ledger data on a BigTable instance") .about("Ledger data on a BigTable instance")
.setting(AppSettings::ArgRequiredElseHelp) .setting(AppSettings::InferSubcommands)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand( .subcommand(
SubCommand::with_name("upload") SubCommand::with_name("upload")
.about("Upload the ledger to BigTable") .about("Upload the ledger to BigTable")

View File

@ -1,7 +1,7 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use clap::{ use clap::{
crate_description, crate_name, value_t, value_t_or_exit, values_t_or_exit, App, Arg, crate_description, crate_name, value_t, value_t_or_exit, values_t_or_exit, App, AppSettings,
ArgMatches, SubCommand, Arg, ArgMatches, SubCommand,
}; };
use itertools::Itertools; use itertools::Itertools;
use log::*; use log::*;
@ -811,6 +811,9 @@ fn main() {
let matches = App::new(crate_name!()) let matches = App::new(crate_name!())
.about(crate_description!()) .about(crate_description!())
.version(solana_version::version!()) .version(solana_version::version!())
.setting(AppSettings::InferSubcommands)
.setting(AppSettings::SubcommandRequiredElseHelp)
.setting(AppSettings::VersionlessSubcommands)
.arg( .arg(
Arg::with_name("ledger_path") Arg::with_name("ledger_path")
.short("l") .short("l")
@ -818,7 +821,8 @@ fn main() {
.value_name("DIR") .value_name("DIR")
.takes_value(true) .takes_value(true)
.global(true) .global(true)
.help("Use DIR for ledger location"), .default_value("ledger")
.help("Use DIR as ledger location"),
) )
.arg( .arg(
Arg::with_name("wal_recovery_mode") Arg::with_name("wal_recovery_mode")
@ -1355,7 +1359,11 @@ fn main() {
// Canonicalize ledger path to avoid issues with symlink creation // Canonicalize ledger path to avoid issues with symlink creation
let ledger_path = fs::canonicalize(&ledger_path).unwrap_or_else(|err| { let ledger_path = fs::canonicalize(&ledger_path).unwrap_or_else(|err| {
eprintln!("Unable to access ledger path: {:?}", err); eprintln!(
"Unable to access ledger path '{}': {}",
ledger_path.display(),
err
);
exit(1); exit(1);
}); });

View File

@ -1042,7 +1042,8 @@ pub fn main() {
.value_name("DIR") .value_name("DIR")
.takes_value(true) .takes_value(true)
.required(true) .required(true)
.help("Use DIR as persistent ledger location"), .default_value("ledger")
.help("Use DIR as ledger location"),
) )
.arg( .arg(
Arg::with_name("entrypoint") Arg::with_name("entrypoint")