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