From ff021d58897db7b927f1b4ba20959be013137961 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 18 Aug 2025 11:52:08 +0200 Subject: [PATCH] =?UTF-8?q?cli:=20Rewrite=20`#[path=3D"=E2=80=A6"]`=20modu?= =?UTF-8?q?le=20declarations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rewrite module declarations that use the `#[path="…"]` annotation to the more idomatic `pub mod …` + `pub use …` forms. For the "self" module, that is not possible because `self` is an identifier in Rust, and also `r#self` is not admissable as a raw identifier, so stick to `rad_self`. Files in submodules were patched as appropriate. --- crates/radicle-cli/src/commands.rs | 91 +++------ crates/radicle-cli/src/commands/clone.rs | 4 +- crates/radicle-cli/src/commands/help.rs | 54 +++--- crates/radicle-cli/src/commands/init.rs | 2 +- crates/radicle-cli/src/commands/issue.rs | 1 - crates/radicle-cli/src/commands/node.rs | 5 +- .../radicle-cli/src/commands/node/control.rs | 4 +- crates/radicle-cli/src/commands/patch.rs | 17 -- .../radicle-cli/src/commands/patch/comment.rs | 3 - .../radicle-cli/src/commands/patch/review.rs | 1 - crates/radicle-cli/src/commands/remote.rs | 4 +- crates/radicle-cli/src/commands/remote/add.rs | 6 +- crates/radicle-cli/src/commands/seed.rs | 2 +- crates/radicle-cli/src/main.rs | 182 +++++------------- 14 files changed, 116 insertions(+), 260 deletions(-) diff --git a/crates/radicle-cli/src/commands.rs b/crates/radicle-cli/src/commands.rs index e4df12c1..0fcfb49e 100644 --- a/crates/radicle-cli/src/commands.rs +++ b/crates/radicle-cli/src/commands.rs @@ -1,62 +1,33 @@ -#[path = "commands/auth.rs"] -pub mod rad_auth; -#[path = "commands/block.rs"] -pub mod rad_block; -#[path = "commands/checkout.rs"] -pub mod rad_checkout; -#[path = "commands/clean.rs"] -pub mod rad_clean; -#[path = "commands/clone.rs"] -pub mod rad_clone; -#[path = "commands/cob.rs"] -pub mod rad_cob; -#[path = "commands/config.rs"] -pub mod rad_config; -#[path = "commands/debug.rs"] -pub mod rad_debug; -#[path = "commands/diff.rs"] -pub mod rad_diff; -#[path = "commands/follow.rs"] -pub mod rad_follow; -#[path = "commands/fork.rs"] -pub mod rad_fork; -#[path = "commands/help.rs"] -pub mod rad_help; -#[path = "commands/id.rs"] -pub mod rad_id; -#[path = "commands/inbox.rs"] -pub mod rad_inbox; -#[path = "commands/init.rs"] -pub mod rad_init; -#[path = "commands/inspect.rs"] -pub mod rad_inspect; -#[path = "commands/issue.rs"] -pub mod rad_issue; -#[path = "commands/ls.rs"] -pub mod rad_ls; -#[path = "commands/node.rs"] -pub mod rad_node; -#[path = "commands/patch.rs"] -pub mod rad_patch; -#[path = "commands/path.rs"] -pub mod rad_path; -#[path = "commands/publish.rs"] -pub mod rad_publish; -#[path = "commands/remote.rs"] -pub mod rad_remote; -#[path = "commands/seed.rs"] -pub mod rad_seed; +pub mod auth; +pub mod block; +pub mod checkout; +pub mod clean; +pub mod clone; +pub mod cob; +pub mod config; +pub mod debug; +pub mod diff; +pub mod follow; +pub mod fork; +pub mod help; +pub mod id; +pub mod inbox; +pub mod init; +pub mod inspect; +pub mod issue; +pub mod ls; +pub mod node; +pub mod patch; +pub mod path; +pub mod publish; +pub mod remote; +pub mod seed; +pub mod stats; +pub mod sync; +pub mod unblock; +pub mod unfollow; +pub mod unseed; +pub mod watch; + #[path = "commands/self.rs"] pub mod rad_self; -#[path = "commands/stats.rs"] -pub mod rad_stats; -#[path = "commands/sync.rs"] -pub mod rad_sync; -#[path = "commands/unblock.rs"] -pub mod rad_unblock; -#[path = "commands/unfollow.rs"] -pub mod rad_unfollow; -#[path = "commands/unseed.rs"] -pub mod rad_unseed; -#[path = "commands/watch.rs"] -pub mod rad_watch; diff --git a/crates/radicle-cli/src/commands/clone.rs b/crates/radicle-cli/src/commands/clone.rs index 771df420..16ed62f5 100644 --- a/crates/radicle-cli/src/commands/clone.rs +++ b/crates/radicle-cli/src/commands/clone.rs @@ -21,8 +21,8 @@ use radicle::storage; use radicle::storage::RemoteId; use radicle::storage::{HasRepoId, RepositoryError}; -use crate::commands::rad_checkout as checkout; -use crate::commands::rad_sync as sync; +use crate::commands::checkout; +use crate::commands::sync; use crate::node::SyncSettings; use crate::project; use crate::terminal as term; diff --git a/crates/radicle-cli/src/commands/help.rs b/crates/radicle-cli/src/commands/help.rs index a1117f48..a4c6d85a 100644 --- a/crates/radicle-cli/src/commands/help.rs +++ b/crates/radicle-cli/src/commands/help.rs @@ -3,8 +3,6 @@ use std::ffi::OsString; use crate::terminal as term; use crate::terminal::args::{Args, Error, Help}; -use super::*; - pub const HELP: Help = Help { name: "help", description: "CLI help", @@ -13,32 +11,32 @@ pub const HELP: Help = Help { }; const COMMANDS: &[Help] = &[ - rad_auth::HELP, - rad_block::HELP, - rad_checkout::HELP, - rad_clone::HELP, - rad_config::HELP, - rad_fork::HELP, - rad_help::HELP, - rad_id::HELP, - rad_init::HELP, - rad_inbox::HELP, - rad_inspect::HELP, - rad_issue::HELP, - rad_ls::HELP, - rad_node::HELP, - rad_patch::HELP, - rad_path::HELP, - rad_clean::HELP, - rad_self::HELP, - rad_seed::HELP, - rad_follow::HELP, - rad_unblock::HELP, - rad_unfollow::HELP, - rad_unseed::HELP, - rad_remote::HELP, - rad_stats::HELP, - rad_sync::HELP, + crate::commands::auth::HELP, + crate::commands::block::HELP, + crate::commands::checkout::HELP, + crate::commands::clone::HELP, + crate::commands::config::HELP, + crate::commands::fork::HELP, + crate::commands::help::HELP, + crate::commands::id::HELP, + crate::commands::init::HELP, + crate::commands::inbox::HELP, + crate::commands::inspect::HELP, + crate::commands::issue::HELP, + crate::commands::ls::HELP, + crate::commands::node::HELP, + crate::commands::patch::HELP, + crate::commands::path::HELP, + crate::commands::clean::HELP, + crate::commands::rad_self::HELP, + crate::commands::seed::HELP, + crate::commands::follow::HELP, + crate::commands::unblock::HELP, + crate::commands::unfollow::HELP, + crate::commands::unseed::HELP, + crate::commands::remote::HELP, + crate::commands::stats::HELP, + crate::commands::sync::HELP, ]; #[derive(Default)] diff --git a/crates/radicle-cli/src/commands/init.rs b/crates/radicle-cli/src/commands/init.rs index 88580dea..967f61b4 100644 --- a/crates/radicle-cli/src/commands/init.rs +++ b/crates/radicle-cli/src/commands/init.rs @@ -448,7 +448,7 @@ fn sync( // Connect to preferred seeds in case we aren't connected. for seed in config.preferred_seeds.iter() { if !sessions.iter().any(|s| s.nid == seed.id) { - commands::rad_node::control::connect( + commands::node::control::connect( node, seed.id, seed.addr.clone(), diff --git a/crates/radicle-cli/src/commands/issue.rs b/crates/radicle-cli/src/commands/issue.rs index 8465cbae..e5404e69 100644 --- a/crates/radicle-cli/src/commands/issue.rs +++ b/crates/radicle-cli/src/commands/issue.rs @@ -1,4 +1,3 @@ -#[path = "issue/cache.rs"] mod cache; use std::collections::BTreeSet; diff --git a/crates/radicle-cli/src/commands/node.rs b/crates/radicle-cli/src/commands/node.rs index 1b9a7da4..209f7715 100644 --- a/crates/radicle-cli/src/commands/node.rs +++ b/crates/radicle-cli/src/commands/node.rs @@ -16,13 +16,10 @@ use crate::terminal as term; use crate::terminal::args::{Args, Error, Help}; use crate::terminal::Element as _; -#[path = "node/commands.rs"] mod commands; -#[path = "node/control.rs"] pub mod control; -#[path = "node/events.rs"] mod events; -#[path = "node/routing.rs"] +mod logs; pub mod routing; pub const HELP: Help = Help { diff --git a/crates/radicle-cli/src/commands/node/control.rs b/crates/radicle-cli/src/commands/node/control.rs index 8876aba6..99e817ee 100644 --- a/crates/radicle-cli/src/commands/node/control.rs +++ b/crates/radicle-cli/src/commands/node/control.rs @@ -1,6 +1,3 @@ -mod logs; -use logs::{LogRotatorFileSystem, Rotated}; - use std::collections::HashMap; use std::ffi::OsString; use std::fs::File; @@ -16,6 +13,7 @@ use radicle::profile::env::RAD_PASSPHRASE; use radicle::Node; use radicle::{profile, Profile}; +use crate::commands::node::logs::{LogRotatorFileSystem, Rotated}; use crate::terminal as term; use crate::terminal::Element as _; diff --git a/crates/radicle-cli/src/commands/patch.rs b/crates/radicle-cli/src/commands/patch.rs index 80382675..67f03ac8 100644 --- a/crates/radicle-cli/src/commands/patch.rs +++ b/crates/radicle-cli/src/commands/patch.rs @@ -1,36 +1,19 @@ -#[path = "patch/archive.rs"] mod archive; -#[path = "patch/assign.rs"] mod assign; -#[path = "patch/cache.rs"] mod cache; -#[path = "patch/checkout.rs"] mod checkout; -#[path = "patch/comment.rs"] mod comment; -#[path = "patch/delete.rs"] mod delete; -#[path = "patch/diff.rs"] mod diff; -#[path = "patch/edit.rs"] mod edit; -#[path = "patch/label.rs"] mod label; -#[path = "patch/list.rs"] mod list; -#[path = "patch/react.rs"] mod react; -#[path = "patch/ready.rs"] mod ready; -#[path = "patch/redact.rs"] mod redact; -#[path = "patch/resolve.rs"] mod resolve; -#[path = "patch/review.rs"] mod review; -#[path = "patch/show.rs"] mod show; -#[path = "patch/update.rs"] mod update; use std::collections::BTreeSet; diff --git a/crates/radicle-cli/src/commands/patch/comment.rs b/crates/radicle-cli/src/commands/patch/comment.rs index fb7694b8..564b403d 100644 --- a/crates/radicle-cli/src/commands/patch/comment.rs +++ b/crates/radicle-cli/src/commands/patch/comment.rs @@ -1,8 +1,5 @@ -#[path = "comment/edit.rs"] pub mod edit; -#[path = "comment/react.rs"] pub mod react; -#[path = "comment/redact.rs"] pub mod redact; use super::*; diff --git a/crates/radicle-cli/src/commands/patch/review.rs b/crates/radicle-cli/src/commands/patch/review.rs index bf8436f1..ac4c7623 100644 --- a/crates/radicle-cli/src/commands/patch/review.rs +++ b/crates/radicle-cli/src/commands/patch/review.rs @@ -1,4 +1,3 @@ -#[path = "review/builder.rs"] mod builder; use anyhow::{anyhow, Context}; diff --git a/crates/radicle-cli/src/commands/remote.rs b/crates/radicle-cli/src/commands/remote.rs index ec64b054..3cae7441 100644 --- a/crates/radicle-cli/src/commands/remote.rs +++ b/crates/radicle-cli/src/commands/remote.rs @@ -1,9 +1,7 @@ //! Remote Command implementation -#[path = "remote/add.rs"] + pub mod add; -#[path = "remote/list.rs"] pub mod list; -#[path = "remote/rm.rs"] pub mod rm; use std::ffi::OsString; diff --git a/crates/radicle-cli/src/commands/remote/add.rs b/crates/radicle-cli/src/commands/remote/add.rs index 62288ff5..89562e86 100644 --- a/crates/radicle-cli/src/commands/remote/add.rs +++ b/crates/radicle-cli/src/commands/remote/add.rs @@ -6,9 +6,9 @@ use radicle::prelude::*; use radicle::Profile; use radicle_crypto::PublicKey; -use crate::commands::rad_checkout as checkout; -use crate::commands::rad_follow as follow; -use crate::commands::rad_sync as sync; +use crate::commands::checkout; +use crate::commands::follow; +use crate::commands::sync; use crate::node::SyncSettings; use crate::project::SetupRemote; diff --git a/crates/radicle-cli/src/commands/seed.rs b/crates/radicle-cli/src/commands/seed.rs index d0cc083f..81a30685 100644 --- a/crates/radicle-cli/src/commands/seed.rs +++ b/crates/radicle-cli/src/commands/seed.rs @@ -11,7 +11,7 @@ use radicle::node::Handle; use radicle::{prelude::*, Node}; use radicle_term::Element as _; -use crate::commands::rad_sync as sync; +use crate::commands::sync; use crate::node::SyncSettings; use crate::terminal as term; use crate::terminal::args::{Args, Error, Help}; diff --git a/crates/radicle-cli/src/main.rs b/crates/radicle-cli/src/main.rs index 4f136d8a..37774ea9 100644 --- a/crates/radicle-cli/src/main.rs +++ b/crates/radicle-cli/src/main.rs @@ -100,7 +100,7 @@ fn print_help() -> anyhow::Result<()> { println!("{DESCRIPTION}"); println!(); - rad_help::run(Default::default(), term::DefaultContext) + help::run(Default::default(), term::DefaultContext) } fn run(command: Command) -> Result<(), Option> { @@ -136,148 +136,82 @@ fn run(command: Command) -> Result<(), Option> { fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option> { match exe { "auth" => { - term::run_command_args::( - rad_auth::HELP, - rad_auth::run, - args.to_vec(), - ); + term::run_command_args::(auth::HELP, auth::run, args.to_vec()); } "block" => { - term::run_command_args::( - rad_block::HELP, - rad_block::run, - args.to_vec(), - ); + term::run_command_args::(block::HELP, block::run, args.to_vec()); } "checkout" => { - term::run_command_args::( - rad_checkout::HELP, - rad_checkout::run, + term::run_command_args::( + checkout::HELP, + checkout::run, args.to_vec(), ); } "clone" => { - term::run_command_args::( - rad_clone::HELP, - rad_clone::run, - args.to_vec(), - ); + term::run_command_args::(clone::HELP, clone::run, args.to_vec()); } "cob" => { - term::run_command_args::( - rad_cob::HELP, - rad_cob::run, - args.to_vec(), - ); + term::run_command_args::(cob::HELP, cob::run, args.to_vec()); } "config" => { - term::run_command_args::( - rad_config::HELP, - rad_config::run, - args.to_vec(), - ); + term::run_command_args::(config::HELP, config::run, args.to_vec()); } "diff" => { - term::run_command_args::( - rad_diff::HELP, - rad_diff::run, - args.to_vec(), - ); + term::run_command_args::(diff::HELP, diff::run, args.to_vec()); } "debug" => { - term::run_command_args::( - rad_debug::HELP, - rad_debug::run, - args.to_vec(), - ); + term::run_command_args::(debug::HELP, debug::run, args.to_vec()); } "follow" => { - term::run_command_args::( - rad_follow::HELP, - rad_follow::run, - args.to_vec(), - ); + term::run_command_args::(follow::HELP, follow::run, args.to_vec()); } "fork" => { - term::run_command_args::( - rad_fork::HELP, - rad_fork::run, - args.to_vec(), - ); + term::run_command_args::(fork::HELP, fork::run, args.to_vec()); } "help" => { - term::run_command_args::( - rad_help::HELP, - rad_help::run, - args.to_vec(), - ); + term::run_command_args::(help::HELP, help::run, args.to_vec()); } "id" => { - term::run_command_args::(rad_id::HELP, rad_id::run, args.to_vec()); + term::run_command_args::(id::HELP, id::run, args.to_vec()); + } + "inbox" => { + term::run_command_args::(inbox::HELP, inbox::run, args.to_vec()) } - "inbox" => term::run_command_args::( - rad_inbox::HELP, - rad_inbox::run, - args.to_vec(), - ), "init" => { - term::run_command_args::( - rad_init::HELP, - rad_init::run, - args.to_vec(), - ); + term::run_command_args::(init::HELP, init::run, args.to_vec()); } "inspect" => { - term::run_command_args::( - rad_inspect::HELP, - rad_inspect::run, + term::run_command_args::( + inspect::HELP, + inspect::run, args.to_vec(), ); } "issue" => { - term::run_command_args::( - rad_issue::HELP, - rad_issue::run, - args.to_vec(), - ); + term::run_command_args::(issue::HELP, issue::run, args.to_vec()); } "ls" => { - term::run_command_args::(rad_ls::HELP, rad_ls::run, args.to_vec()); + term::run_command_args::(ls::HELP, ls::run, args.to_vec()); } "node" => { - term::run_command_args::( - rad_node::HELP, - rad_node::run, - args.to_vec(), - ); + term::run_command_args::(node::HELP, node::run, args.to_vec()); } "patch" => { - term::run_command_args::( - rad_patch::HELP, - rad_patch::run, - args.to_vec(), - ); + term::run_command_args::(patch::HELP, patch::run, args.to_vec()); } "path" => { - term::run_command_args::( - rad_path::HELP, - rad_path::run, - args.to_vec(), - ); + term::run_command_args::(path::HELP, path::run, args.to_vec()); } "publish" => { - term::run_command_args::( - rad_publish::HELP, - rad_publish::run, + term::run_command_args::( + publish::HELP, + publish::run, args.to_vec(), ); } "clean" => { - term::run_command_args::( - rad_clean::HELP, - rad_clean::run, - args.to_vec(), - ); + term::run_command_args::(clean::HELP, clean::run, args.to_vec()); } "self" => { term::run_command_args::( @@ -287,55 +221,37 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option> ); } "sync" => { - term::run_command_args::( - rad_sync::HELP, - rad_sync::run, - args.to_vec(), - ); + term::run_command_args::(sync::HELP, sync::run, args.to_vec()); } "seed" => { - term::run_command_args::( - rad_seed::HELP, - rad_seed::run, - args.to_vec(), - ); + term::run_command_args::(seed::HELP, seed::run, args.to_vec()); } "unblock" => { - term::run_command_args::( - rad_unblock::HELP, - rad_unblock::run, + term::run_command_args::( + unblock::HELP, + unblock::run, args.to_vec(), ); } "unfollow" => { - term::run_command_args::( - rad_unfollow::HELP, - rad_unfollow::run, + term::run_command_args::( + unfollow::HELP, + unfollow::run, args.to_vec(), ); } "unseed" => { - term::run_command_args::( - rad_unseed::HELP, - rad_unseed::run, - args.to_vec(), - ); + term::run_command_args::(unseed::HELP, unseed::run, args.to_vec()); + } + "remote" => { + term::run_command_args::(remote::HELP, remote::run, args.to_vec()) + } + "stats" => { + term::run_command_args::(stats::HELP, stats::run, args.to_vec()) + } + "watch" => { + term::run_command_args::(watch::HELP, watch::run, args.to_vec()) } - "remote" => term::run_command_args::( - rad_remote::HELP, - rad_remote::run, - args.to_vec(), - ), - "stats" => term::run_command_args::( - rad_stats::HELP, - rad_stats::run, - args.to_vec(), - ), - "watch" => term::run_command_args::( - rad_watch::HELP, - rad_watch::run, - args.to_vec(), - ), other => { let exe = format!("{NAME}-{exe}"); let status = process::Command::new(exe).args(args).status();