config command
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
use crate::error::NymvisorError;
|
||||
use nym_bin_common::output_format::OutputFormat;
|
||||
use crate::cli::try_load_current_config;
|
||||
use crate::env::Env;
|
||||
|
||||
#[derive(clap::Args, Debug)]
|
||||
pub(crate) struct Args {
|
||||
@@ -11,6 +13,9 @@ pub(crate) struct Args {
|
||||
}
|
||||
|
||||
pub(crate) fn execute(args: Args) -> Result<(), NymvisorError> {
|
||||
println!("config");
|
||||
let env = Env::try_read()?;
|
||||
let config = try_load_current_config(&env)?;
|
||||
|
||||
println!("{}", args.output.format(&config));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use nym_config::{
|
||||
DEFAULT_CONFIG_DIR, DEFAULT_CONFIG_FILENAME, DEFAULT_DATA_DIR, NYM_DIR,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
@@ -86,6 +86,71 @@ impl NymConfigTemplate for Config {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Config {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
r#"
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{:?}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{}
|
||||
{:<35}{:?}
|
||||
{:<35}{}
|
||||
"#,
|
||||
"id:",
|
||||
self.nymvisor.id,
|
||||
"daemon name:",
|
||||
self.daemon.name,
|
||||
"daemon home:",
|
||||
self.daemon.home.display(),
|
||||
"disable nymvisor logs:",
|
||||
self.nymvisor.debug.disable_logs,
|
||||
"CUSTOM upgrade data directory",
|
||||
self.nymvisor
|
||||
.debug
|
||||
.upgrade_data_directory
|
||||
.as_ref()
|
||||
.map(|p| p.display().to_string())
|
||||
.unwrap_or_default(),
|
||||
"allow binaries download:",
|
||||
self.daemon.debug.allow_binaries_download,
|
||||
"enforce download checksum:",
|
||||
self.daemon.debug.enforce_download_checksum,
|
||||
"restart after upgrade:",
|
||||
self.daemon.debug.restart_after_upgrade,
|
||||
"restart on failure:",
|
||||
self.daemon.debug.restart_on_failure,
|
||||
"on failure restart delay:",
|
||||
humantime::format_duration(self.daemon.debug.failure_restart_delay),
|
||||
"max startup failures:",
|
||||
self.daemon.debug.max_startup_failures,
|
||||
"startup period duration:",
|
||||
humantime::format_duration(self.daemon.debug.startup_period_duration),
|
||||
"shutdown grace period:",
|
||||
humantime::format_duration(self.daemon.debug.shutdown_grace_period),
|
||||
"CUSTOM backup data directory",
|
||||
self.daemon
|
||||
.debug
|
||||
.backup_data_directory
|
||||
.as_ref()
|
||||
.map(|p| p.display().to_string())
|
||||
.unwrap_or_default(),
|
||||
"UNSAFE skip backups",
|
||||
self.daemon.debug.unsafe_skip_backup,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn default_id<S: Display>(daemon_name: S) -> String {
|
||||
format!("{daemon_name}-default")
|
||||
|
||||
Reference in New Issue
Block a user