mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 05:31:09 +00:00
Refactor CLI handling (#1368)
* Rework cli handling * Update readme * Adds support for custom subcommands and extra run parameters * Update readme * Fixes compilation after master merge * Make "Run" the default subcommand Actually its hidden to the outside that is an subcommand. * Rewrite CLI to work without breaking old CLI behavior * Some cleanup * Fix incorrect config setup * Update README * Fixes after merge * Fixes incorrect README
This commit is contained in:
@@ -25,16 +25,23 @@ use std::{fs, path::Path};
|
||||
const SECRET_FILE: &str = "secret";
|
||||
|
||||
/// Obtains or generates the local private key using the configuration.
|
||||
pub fn obtain_private_key(
|
||||
pub fn obtain_private_key_from_config(
|
||||
config: &NetworkConfiguration
|
||||
) -> Result<secio::SecioKeyPair, IoError> {
|
||||
if let Some(ref secret) = config.use_secret {
|
||||
obtain_private_key(&config.use_secret, &config.net_config_path)
|
||||
}
|
||||
|
||||
/// Obtains or generates the local private key using the configuration.
|
||||
pub fn obtain_private_key(
|
||||
secret: &Option<[u8; 32]>,
|
||||
net_config_path: &Option<String>,
|
||||
) -> Result<secio::SecioKeyPair, IoError> {
|
||||
if let Some(ref secret) = secret {
|
||||
// Key was specified in the configuration.
|
||||
secio::SecioKeyPair::secp256k1_raw_key(&secret[..])
|
||||
.map_err(|err| IoError::new(IoErrorKind::InvalidData, err))
|
||||
|
||||
} else {
|
||||
if let Some(ref path) = config.net_config_path {
|
||||
if let Some(ref path) = net_config_path {
|
||||
// Try fetch the key from a the file containing the secret.
|
||||
let secret_path = Path::new(path).join(SECRET_FILE);
|
||||
match load_private_key_from_file(&secret_path) {
|
||||
|
||||
Reference in New Issue
Block a user