reth_cli_commands/
config_cmd.rs
1use clap::Parser;
4use eyre::{bail, WrapErr};
5use reth_config::Config;
6use std::path::PathBuf;
7#[derive(Debug, Parser)]
9pub struct Command {
10 #[arg(long, value_name = "FILE", verbatim_doc_comment)]
12 config: Option<PathBuf>,
13
14 #[arg(long, verbatim_doc_comment, conflicts_with = "config")]
16 default: bool,
17}
18
19impl Command {
20 pub async fn execute(&self) -> eyre::Result<()> {
22 let config = if self.default {
23 Config::default()
24 } else {
25 let path = self.config.clone().unwrap_or_default();
26 if !path.exists() {
28 bail!("Config file does not exist: {}", path.display());
29 }
30 Config::from_path(&path)
32 .wrap_err_with(|| format!("Could not load config file: {}", path.display()))?
33 };
34 println!("{}", toml::to_string_pretty(&config)?);
35 Ok(())
36 }
37}