Skip to content

Commit

Permalink
feat(iroh-cli): simplify config loading (#2171)
Browse files Browse the repository at this point in the history
Loads the configuration from either the default path, or the passed in
configuration path. Dropping the `config` dependency and simplifying the
structure.

Removes unused overrides and detailed configuration via env variables.

---------

Co-authored-by: Diva M <divma@protonmail.com>
  • Loading branch information
dignifiedquire and divagant-martian committed Apr 15, 2024
1 parent 72384ce commit 2cfa055
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 175 deletions.
57 changes: 3 additions & 54 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions iroh-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ doc = false

[dependencies]
anyhow = "1.0.81"
bao-tree = { version = "0.13" }
bao-tree = "0.13"
bytes = "1.5.0"
clap = { version = "4", features = ["derive"] }
colored = { version = "2.0.4" }
comfy-table = { version = "7.0.1" }
config = { version = "0.13.1", default-features = false, features = ["toml", "preserve_order"] }
console = { version = "0.15.5" }
colored = "2.0.4"
comfy-table = "7.0.1"
console = "0.15.5"
derive_more = { version = "1.0.0-beta.1", features = ["display"] }
dialoguer = { version = "0.11.0", default-features = false }
dirs-next = { version = "2.0.0" }
dirs-next = "2.0.0"
flume = "0.11.0"
futures = "0.3.30"
hex = "0.4.3"
human-time = { version = "0.1.6" }
human-time = "0.1.6"
indicatif = { version = "0.17", features = ["tokio"] }
iroh = { version = "0.13.0", path = "../iroh", features = ["metrics"] }
iroh-metrics = { version = "0.13.0", path = "../iroh-metrics" }
Expand All @@ -46,16 +45,17 @@ postcard = "1.0.8"
quic-rpc = { version = "0.7.0", features = ["flume-transport", "quinn-transport"] }
quinn = "0.10.2"
rand = "0.8.5"
rustyline = { version = "12.0.0" }
rustyline = "12.0.0"
serde = { version = "1.0.197", features = ["derive"] }
serde_with = "3.7.0"
shell-words = { version = "1.1.0" }
shellexpand = { version = "3.1.0" }
shell-words = "1.1.0"
shellexpand = "3.1.0"
strum = { version = "0.26.2", features = ["derive"] }
tempfile = "3.10.1"
thiserror = "1.0.58"
time = { version = "0.3", features = ["formatting"] }
tokio = { version = "1.36.0", features = ["full"] }
toml = { version = "0.8.12", features = ["preserve_order"] }
tracing = "0.1.40"
tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
Expand Down
8 changes: 4 additions & 4 deletions iroh-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl Cli {
Commands::Console => {
let env = ConsoleEnv::for_console(data_dir)?;
if self.start {
let config = NodeConfig::from_env(self.config.as_deref())?;
let config = NodeConfig::load(self.config.as_deref()).await?;
start::run_with_command(
&config,
data_dir,
Expand All @@ -134,7 +134,7 @@ impl Cli {
Commands::Rpc(command) => {
let env = ConsoleEnv::for_cli(data_dir)?;
if self.start {
let config = NodeConfig::from_env(self.config.as_deref())?;
let config = NodeConfig::load(self.config.as_deref()).await?;
start::run_with_command(
&config,
data_dir,
Expand All @@ -157,7 +157,7 @@ impl Cli {
path.display()
);
}
let mut config = NodeConfig::from_env(self.config.as_deref())?;
let mut config = NodeConfig::load(self.config.as_deref()).await?;
if let Some(metrics_port) = self.metrics_port {
config.metrics_addr = match metrics_port {
MetricsPort::Disabled => None,
Expand All @@ -184,7 +184,7 @@ impl Cli {
.await
}
Commands::Doctor { command } => {
let config = NodeConfig::from_env(self.config.as_deref())?;
let config = NodeConfig::load(self.config.as_deref()).await?;
self::doctor::run(command, &config).await
}
}
Expand Down
2 changes: 1 addition & 1 deletion iroh-cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ pub async fn run(command: Commands, config: &NodeConfig) -> anyhow::Result<()> {
port_map_probe(config).await
}
Commands::RelayUrls { count } => {
let config = NodeConfig::from_env(None)?;
let config = NodeConfig::load(None).await?;
relay_urls(count, config).await
}
Commands::TicketInspect { ticket } => inspect_ticket(&ticket),
Expand Down
Loading

0 comments on commit 2cfa055

Please sign in to comment.