Skip to content

Commit ad91831

Browse files
authored
refactor(iroh-cli)!: Use docs and authors cli from iroh-docs crate (#2947)
## Description Use the cli args and handlers from the iroh-docs crate ## Breaking Changes ## Notes & open questions Note: identical to #2944 ## Change checklist - [x] Self-review. - [x] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [x] Tests if relevant. - [x] All breaking changes documented.
1 parent f9e883d commit ad91831

File tree

8 files changed

+25
-1341
lines changed

8 files changed

+25
-1341
lines changed

Cargo.lock

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ human-time = "0.1.6"
4242
indicatif = { version = "0.17", features = ["tokio"] }
4343
iroh = { version = "0.28.1", path = "../iroh", features = ["metrics"] }
4444
iroh-gossip = "0.28.1"
45-
iroh-docs = { version = "0.28.0", features = ["rpc"]}
45+
iroh-docs = { version = "0.28.0", features = ["rpc", "cli"]}
4646
iroh-metrics = { version = "0.28.0" }
4747
iroh-blobs = { version = "0.28.1", features = ["cli"] }
4848
parking_lot = "0.12.1"

iroh-cli/src/commands.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ use anyhow::{ensure, Context, Result};
77
use clap::Parser;
88
use iroh::client::Iroh;
99
use iroh_blobs::cli::{BlobAddOptions, BlobSource};
10+
use iroh_docs::cli::ConsoleEnv;
1011

1112
use self::{rpc::RpcCommands, start::RunType};
12-
use crate::config::{ConsoleEnv, NodeConfig};
13+
use crate::config::NodeConfig;
1314

14-
pub(crate) mod authors;
1515
pub(crate) mod console;
16-
pub(crate) mod docs;
1716
pub(crate) mod doctor;
1817
pub(crate) mod gossip;
1918
pub(crate) mod net;
2019
pub(crate) mod rpc;
2120
pub(crate) mod start;
2221
pub(crate) use iroh_blobs::{cli as blobs, cli::tags};
22+
pub(crate) use iroh_docs::{cli as docs, cli::authors};
2323

2424
/// iroh is a tool for building distributed apps.
2525
///
@@ -121,7 +121,8 @@ impl Cli {
121121
self.rpc_addr,
122122
RunType::SingleCommandNoAbort,
123123
|iroh| async move {
124-
let env = ConsoleEnv::for_console(data_dir_owned, &iroh).await?;
124+
let env =
125+
ConsoleEnv::for_console(data_dir_owned, &iroh.authors()).await?;
125126
console::run(&iroh, &env).await
126127
},
127128
)
@@ -133,7 +134,7 @@ impl Cli {
133134
} else {
134135
Iroh::connect_path(data_dir).await.context("rpc connect")?
135136
};
136-
let env = ConsoleEnv::for_console(data_dir_owned, &iroh).await?;
137+
let env = ConsoleEnv::for_console(data_dir_owned, &iroh.authors()).await?;
137138
console::run(&iroh, &env).await
138139
}
139140
}
@@ -147,7 +148,7 @@ impl Cli {
147148
self.rpc_addr,
148149
RunType::SingleCommandAbortable,
149150
move |iroh| async move {
150-
let env = ConsoleEnv::for_cli(data_dir_owned, &iroh).await?;
151+
let env = ConsoleEnv::for_cli(data_dir_owned, &iroh.authors()).await?;
151152
command.run(&iroh, &env).await
152153
},
153154
)
@@ -159,7 +160,7 @@ impl Cli {
159160
} else {
160161
Iroh::connect_path(data_dir).await.context("rpc connect")?
161162
};
162-
let env = ConsoleEnv::for_cli(data_dir_owned, &iroh).await?;
163+
let env = ConsoleEnv::for_cli(data_dir_owned, &iroh.authors()).await?;
163164
command.run(&iroh, &env).await
164165
}
165166
}

iroh-cli/src/commands/authors.rs

Lines changed: 0 additions & 106 deletions
This file was deleted.

iroh-cli/src/commands/console.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ use anyhow::Result;
44
use clap::{Parser, Subcommand};
55
use colored::Colorize;
66
use iroh::{base::base32::fmt_short, client::Iroh};
7+
use iroh_docs::cli::ConsoleEnv;
78
use rustyline::{error::ReadlineError, Config, DefaultEditor};
89
use tokio::sync::{mpsc, oneshot};
910

10-
use crate::{
11-
commands::rpc::RpcCommands,
12-
config::{ConsoleEnv, ConsolePaths},
13-
};
11+
use crate::{commands::rpc::RpcCommands, config::ConsolePaths};
1412

1513
/// Runs the iroh console
1614
pub async fn run(iroh: &Iroh, env: &ConsoleEnv) -> Result<()> {

0 commit comments

Comments
 (0)