ledger-tool: Remove unnecessary function to parse ledger path arg (#29952)
This commit is contained in:
parent
7bcb3cef02
commit
90f8c86d23
|
@ -1,22 +1,9 @@
|
||||||
use {
|
use std::{
|
||||||
clap::{value_t, ArgMatches},
|
|
||||||
std::{
|
|
||||||
fs,
|
fs,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::exit,
|
process::exit,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn parse_ledger_path(matches: &ArgMatches<'_>, name: &str) -> PathBuf {
|
|
||||||
PathBuf::from(value_t!(matches, name, String).unwrap_or_else(|_err| {
|
|
||||||
eprintln!(
|
|
||||||
"Error: Missing --ledger <DIR> argument.\n\n{}",
|
|
||||||
matches.usage()
|
|
||||||
);
|
|
||||||
exit(1);
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Canonicalize ledger path to avoid issues with symlink creation
|
// Canonicalize ledger path to avoid issues with symlink creation
|
||||||
pub fn canonicalize_ledger_path(ledger_path: &Path) -> PathBuf {
|
pub fn canonicalize_ledger_path(ledger_path: &Path) -> PathBuf {
|
||||||
fs::canonicalize(ledger_path).unwrap_or_else(|err| {
|
fs::canonicalize(ledger_path).unwrap_or_else(|err| {
|
||||||
|
|
|
@ -2312,8 +2312,7 @@ fn main() {
|
||||||
|
|
||||||
info!("{} {}", crate_name!(), solana_version::version!());
|
info!("{} {}", crate_name!(), solana_version::version!());
|
||||||
|
|
||||||
let ledger_path = parse_ledger_path(&matches, "ledger_path");
|
let ledger_path = PathBuf::from(value_t_or_exit!(matches, "ledger_path", String));
|
||||||
|
|
||||||
let snapshot_archive_path = value_t!(matches, "snapshot_archive_path", String)
|
let snapshot_archive_path = value_t!(matches, "snapshot_archive_path", String)
|
||||||
.ok()
|
.ok()
|
||||||
.map(PathBuf::from);
|
.map(PathBuf::from);
|
||||||
|
|
Loading…
Reference in New Issue