reth_cli_commands/
config_cmd.rs1use 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 = match self.config.as_ref() {
26 Some(path) => path,
27 None => {
28 bail!("No config file provided. Use --config <FILE> or pass --default");
29 }
30 };
31 if !path.exists() {
32 bail!("Config file does not exist: {}", path.display());
33 }
34 Config::from_path(path)
35 .wrap_err_with(|| format!("Could not load config file: {}", path.display()))?
36 };
37 println!("{}", toml::to_string_pretty(&config)?);
38 Ok(())
39 }
40}