Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f19bcea

Browse files
committedMar 18, 2025··
refacto: Use register_config_value in mithril-client-cli
1 parent 46093ff commit f19bcea

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed
 

‎Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mithril-client-cli/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fs2 = "0.4.3"
3232
futures = "0.3.31"
3333
human_bytes = { version = "0.4.3", features = ["fast"] }
3434
indicatif = { version = "0.17.11", features = ["tokio"] }
35+
mithril-cli-helper = { path = "../internal/mithril-cli-helper" }
3536
mithril-client = { path = "../mithril-client", features = ["fs", "unstable"] }
3637
mithril-doc = { path = "../internal/mithril-doc" }
3738
serde = { version = "1.0.217", features = ["derive"] }

‎mithril-client-cli/src/main.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
use anyhow::{anyhow, Context};
44
use clap::{CommandFactory, Parser, Subcommand};
5-
use config::{builder::DefaultState, ConfigBuilder, Map, Source, Value, ValueKind};
5+
use config::{builder::DefaultState, ConfigBuilder, Map, Source, Value};
6+
use mithril_cli_helper::{register_config_value, register_config_value_option};
67
use slog::{debug, Drain, Fuse, Level, Logger};
78
use slog_term::Decorator;
89
use std::io::Write;
@@ -177,12 +178,8 @@ impl Source for Args {
177178
let mut map = Map::new();
178179
let namespace = "clap arguments".to_string();
179180

180-
if let Some(aggregator_endpoint) = self.aggregator_endpoint.clone() {
181-
map.insert(
182-
"aggregator_endpoint".to_string(),
183-
Value::new(Some(&namespace), ValueKind::from(aggregator_endpoint)),
184-
);
185-
}
181+
let myself = self.clone();
182+
register_config_value_option!(map, &namespace, myself.aggregator_endpoint);
186183

187184
Ok(map)
188185
}

0 commit comments

Comments
 (0)
Please sign in to comment.