Skip to content

Commit

Permalink
refactor(iroh-cli)!: Use docs and authors cli from iroh-docs crate (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
rklaehn authored Nov 18, 2024
1 parent f9e883d commit ad91831
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 1,341 deletions.
10 changes: 9 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion iroh-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ human-time = "0.1.6"
indicatif = { version = "0.17", features = ["tokio"] }
iroh = { version = "0.28.1", path = "../iroh", features = ["metrics"] }
iroh-gossip = "0.28.1"
iroh-docs = { version = "0.28.0", features = ["rpc"]}
iroh-docs = { version = "0.28.0", features = ["rpc", "cli"]}
iroh-metrics = { version = "0.28.0" }
iroh-blobs = { version = "0.28.1", features = ["cli"] }
parking_lot = "0.12.1"
Expand Down
15 changes: 8 additions & 7 deletions iroh-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ use anyhow::{ensure, Context, Result};
use clap::Parser;
use iroh::client::Iroh;
use iroh_blobs::cli::{BlobAddOptions, BlobSource};
use iroh_docs::cli::ConsoleEnv;

use self::{rpc::RpcCommands, start::RunType};
use crate::config::{ConsoleEnv, NodeConfig};
use crate::config::NodeConfig;

pub(crate) mod authors;
pub(crate) mod console;
pub(crate) mod docs;
pub(crate) mod doctor;
pub(crate) mod gossip;
pub(crate) mod net;
pub(crate) mod rpc;
pub(crate) mod start;
pub(crate) use iroh_blobs::{cli as blobs, cli::tags};
pub(crate) use iroh_docs::{cli as docs, cli::authors};

/// iroh is a tool for building distributed apps.
///
Expand Down Expand Up @@ -121,7 +121,8 @@ impl Cli {
self.rpc_addr,
RunType::SingleCommandNoAbort,
|iroh| async move {
let env = ConsoleEnv::for_console(data_dir_owned, &iroh).await?;
let env =
ConsoleEnv::for_console(data_dir_owned, &iroh.authors()).await?;
console::run(&iroh, &env).await
},
)
Expand All @@ -133,7 +134,7 @@ impl Cli {
} else {
Iroh::connect_path(data_dir).await.context("rpc connect")?
};
let env = ConsoleEnv::for_console(data_dir_owned, &iroh).await?;
let env = ConsoleEnv::for_console(data_dir_owned, &iroh.authors()).await?;
console::run(&iroh, &env).await
}
}
Expand All @@ -147,7 +148,7 @@ impl Cli {
self.rpc_addr,
RunType::SingleCommandAbortable,
move |iroh| async move {
let env = ConsoleEnv::for_cli(data_dir_owned, &iroh).await?;
let env = ConsoleEnv::for_cli(data_dir_owned, &iroh.authors()).await?;
command.run(&iroh, &env).await
},
)
Expand All @@ -159,7 +160,7 @@ impl Cli {
} else {
Iroh::connect_path(data_dir).await.context("rpc connect")?
};
let env = ConsoleEnv::for_cli(data_dir_owned, &iroh).await?;
let env = ConsoleEnv::for_cli(data_dir_owned, &iroh.authors()).await?;
command.run(&iroh, &env).await
}
}
Expand Down
106 changes: 0 additions & 106 deletions iroh-cli/src/commands/authors.rs

This file was deleted.

6 changes: 2 additions & 4 deletions iroh-cli/src/commands/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ use anyhow::Result;
use clap::{Parser, Subcommand};
use colored::Colorize;
use iroh::{base::base32::fmt_short, client::Iroh};
use iroh_docs::cli::ConsoleEnv;
use rustyline::{error::ReadlineError, Config, DefaultEditor};
use tokio::sync::{mpsc, oneshot};

use crate::{
commands::rpc::RpcCommands,
config::{ConsoleEnv, ConsolePaths},
};
use crate::{commands::rpc::RpcCommands, config::ConsolePaths};

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

0 comments on commit ad91831

Please sign in to comment.