Consider config in check_for_usb (#9555)
This commit is contained in:
parent
9bba27a3aa
commit
a9c38fb0df
|
@ -16,7 +16,7 @@ use solana_cli_config::{Config, CONFIG_FILE};
|
||||||
use solana_remote_wallet::remote_wallet::{maybe_wallet_manager, RemoteWalletManager};
|
use solana_remote_wallet::remote_wallet::{maybe_wallet_manager, RemoteWalletManager};
|
||||||
use std::{error, sync::Arc};
|
use std::{error, sync::Arc};
|
||||||
|
|
||||||
fn parse_settings(matches: &ArgMatches<'_>) -> Result<bool, Box<dyn error::Error>> {
|
fn parse_settings(matches: &ArgMatches<'_>) -> Result<Option<bool>, Box<dyn error::Error>> {
|
||||||
let parse_args = match matches.subcommand() {
|
let parse_args = match matches.subcommand() {
|
||||||
("config", Some(matches)) => match matches.subcommand() {
|
("config", Some(matches)) => match matches.subcommand() {
|
||||||
("get", Some(subcommand_matches)) => {
|
("get", Some(subcommand_matches)) => {
|
||||||
|
@ -54,7 +54,7 @@ fn parse_settings(matches: &ArgMatches<'_>) -> Result<bool, Box<dyn error::Error
|
||||||
style("No config file found.").bold()
|
style("No config file found.").bold()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
false
|
None
|
||||||
}
|
}
|
||||||
("set", Some(subcommand_matches)) => {
|
("set", Some(subcommand_matches)) => {
|
||||||
if let Some(config_file) = matches.value_of("config_file") {
|
if let Some(config_file) = matches.value_of("config_file") {
|
||||||
|
@ -94,11 +94,19 @@ fn parse_settings(matches: &ArgMatches<'_>) -> Result<bool, Box<dyn error::Error
|
||||||
style("No config file found.").bold()
|
style("No config file found.").bold()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
false
|
None
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
_ => true,
|
_ => {
|
||||||
|
let need_wallet_manager = if let Some(config_file) = matches.value_of("config_file") {
|
||||||
|
let config = Config::load(config_file).unwrap_or_default();
|
||||||
|
check_for_usb([config.keypair_path].iter())
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
Some(need_wallet_manager)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Ok(parse_args)
|
Ok(parse_args)
|
||||||
}
|
}
|
||||||
|
@ -262,8 +270,8 @@ fn do_main(
|
||||||
matches: &ArgMatches<'_>,
|
matches: &ArgMatches<'_>,
|
||||||
need_wallet_manager: bool,
|
need_wallet_manager: bool,
|
||||||
) -> Result<(), Box<dyn error::Error>> {
|
) -> Result<(), Box<dyn error::Error>> {
|
||||||
if parse_settings(&matches)? {
|
if let Some(config_need_wallet_manager) = parse_settings(&matches)? {
|
||||||
let wallet_manager = if need_wallet_manager {
|
let wallet_manager = if need_wallet_manager || config_need_wallet_manager {
|
||||||
maybe_wallet_manager()?
|
maybe_wallet_manager()?
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -407,11 +407,12 @@ fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box<dyn error::Error>> {
|
||||||
Config::default()
|
Config::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let wallet_manager = if check_for_usb(std::env::args()) {
|
let wallet_manager =
|
||||||
maybe_wallet_manager()?
|
if check_for_usb(std::env::args()) || check_for_usb([config.keypair_path.clone()].iter()) {
|
||||||
} else {
|
maybe_wallet_manager()?
|
||||||
None
|
} else {
|
||||||
};
|
None
|
||||||
|
};
|
||||||
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
("pubkey", Some(matches)) => {
|
("pubkey", Some(matches)) => {
|
||||||
|
|
Loading…
Reference in New Issue