cli: Rewrite `#[path="…"]` module declarations

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.
This commit is contained in:
Matthias Beyer 2025-08-18 11:52:08 +02:00 committed by Lorenz Leutgeb
parent 11fc98c9c9
commit ff021d5889
14 changed files with 116 additions and 260 deletions

View File

@ -1,62 +1,33 @@
#[path = "commands/auth.rs"] pub mod auth;
pub mod rad_auth; pub mod block;
#[path = "commands/block.rs"] pub mod checkout;
pub mod rad_block; pub mod clean;
#[path = "commands/checkout.rs"] pub mod clone;
pub mod rad_checkout; pub mod cob;
#[path = "commands/clean.rs"] pub mod config;
pub mod rad_clean; pub mod debug;
#[path = "commands/clone.rs"] pub mod diff;
pub mod rad_clone; pub mod follow;
#[path = "commands/cob.rs"] pub mod fork;
pub mod rad_cob; pub mod help;
#[path = "commands/config.rs"] pub mod id;
pub mod rad_config; pub mod inbox;
#[path = "commands/debug.rs"] pub mod init;
pub mod rad_debug; pub mod inspect;
#[path = "commands/diff.rs"] pub mod issue;
pub mod rad_diff; pub mod ls;
#[path = "commands/follow.rs"] pub mod node;
pub mod rad_follow; pub mod patch;
#[path = "commands/fork.rs"] pub mod path;
pub mod rad_fork; pub mod publish;
#[path = "commands/help.rs"] pub mod remote;
pub mod rad_help; pub mod seed;
#[path = "commands/id.rs"] pub mod stats;
pub mod rad_id; pub mod sync;
#[path = "commands/inbox.rs"] pub mod unblock;
pub mod rad_inbox; pub mod unfollow;
#[path = "commands/init.rs"] pub mod unseed;
pub mod rad_init; pub mod watch;
#[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;
#[path = "commands/self.rs"] #[path = "commands/self.rs"]
pub mod rad_self; 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;

View File

@ -21,8 +21,8 @@ use radicle::storage;
use radicle::storage::RemoteId; use radicle::storage::RemoteId;
use radicle::storage::{HasRepoId, RepositoryError}; use radicle::storage::{HasRepoId, RepositoryError};
use crate::commands::rad_checkout as checkout; use crate::commands::checkout;
use crate::commands::rad_sync as sync; use crate::commands::sync;
use crate::node::SyncSettings; use crate::node::SyncSettings;
use crate::project; use crate::project;
use crate::terminal as term; use crate::terminal as term;

View File

@ -3,8 +3,6 @@ use std::ffi::OsString;
use crate::terminal as term; use crate::terminal as term;
use crate::terminal::args::{Args, Error, Help}; use crate::terminal::args::{Args, Error, Help};
use super::*;
pub const HELP: Help = Help { pub const HELP: Help = Help {
name: "help", name: "help",
description: "CLI help", description: "CLI help",
@ -13,32 +11,32 @@ pub const HELP: Help = Help {
}; };
const COMMANDS: &[Help] = &[ const COMMANDS: &[Help] = &[
rad_auth::HELP, crate::commands::auth::HELP,
rad_block::HELP, crate::commands::block::HELP,
rad_checkout::HELP, crate::commands::checkout::HELP,
rad_clone::HELP, crate::commands::clone::HELP,
rad_config::HELP, crate::commands::config::HELP,
rad_fork::HELP, crate::commands::fork::HELP,
rad_help::HELP, crate::commands::help::HELP,
rad_id::HELP, crate::commands::id::HELP,
rad_init::HELP, crate::commands::init::HELP,
rad_inbox::HELP, crate::commands::inbox::HELP,
rad_inspect::HELP, crate::commands::inspect::HELP,
rad_issue::HELP, crate::commands::issue::HELP,
rad_ls::HELP, crate::commands::ls::HELP,
rad_node::HELP, crate::commands::node::HELP,
rad_patch::HELP, crate::commands::patch::HELP,
rad_path::HELP, crate::commands::path::HELP,
rad_clean::HELP, crate::commands::clean::HELP,
rad_self::HELP, crate::commands::rad_self::HELP,
rad_seed::HELP, crate::commands::seed::HELP,
rad_follow::HELP, crate::commands::follow::HELP,
rad_unblock::HELP, crate::commands::unblock::HELP,
rad_unfollow::HELP, crate::commands::unfollow::HELP,
rad_unseed::HELP, crate::commands::unseed::HELP,
rad_remote::HELP, crate::commands::remote::HELP,
rad_stats::HELP, crate::commands::stats::HELP,
rad_sync::HELP, crate::commands::sync::HELP,
]; ];
#[derive(Default)] #[derive(Default)]

View File

@ -448,7 +448,7 @@ fn sync(
// Connect to preferred seeds in case we aren't connected. // Connect to preferred seeds in case we aren't connected.
for seed in config.preferred_seeds.iter() { for seed in config.preferred_seeds.iter() {
if !sessions.iter().any(|s| s.nid == seed.id) { if !sessions.iter().any(|s| s.nid == seed.id) {
commands::rad_node::control::connect( commands::node::control::connect(
node, node,
seed.id, seed.id,
seed.addr.clone(), seed.addr.clone(),

View File

@ -1,4 +1,3 @@
#[path = "issue/cache.rs"]
mod cache; mod cache;
use std::collections::BTreeSet; use std::collections::BTreeSet;

View File

@ -16,13 +16,10 @@ use crate::terminal as term;
use crate::terminal::args::{Args, Error, Help}; use crate::terminal::args::{Args, Error, Help};
use crate::terminal::Element as _; use crate::terminal::Element as _;
#[path = "node/commands.rs"]
mod commands; mod commands;
#[path = "node/control.rs"]
pub mod control; pub mod control;
#[path = "node/events.rs"]
mod events; mod events;
#[path = "node/routing.rs"] mod logs;
pub mod routing; pub mod routing;
pub const HELP: Help = Help { pub const HELP: Help = Help {

View File

@ -1,6 +1,3 @@
mod logs;
use logs::{LogRotatorFileSystem, Rotated};
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs::File; use std::fs::File;
@ -16,6 +13,7 @@ use radicle::profile::env::RAD_PASSPHRASE;
use radicle::Node; use radicle::Node;
use radicle::{profile, Profile}; use radicle::{profile, Profile};
use crate::commands::node::logs::{LogRotatorFileSystem, Rotated};
use crate::terminal as term; use crate::terminal as term;
use crate::terminal::Element as _; use crate::terminal::Element as _;

View File

@ -1,36 +1,19 @@
#[path = "patch/archive.rs"]
mod archive; mod archive;
#[path = "patch/assign.rs"]
mod assign; mod assign;
#[path = "patch/cache.rs"]
mod cache; mod cache;
#[path = "patch/checkout.rs"]
mod checkout; mod checkout;
#[path = "patch/comment.rs"]
mod comment; mod comment;
#[path = "patch/delete.rs"]
mod delete; mod delete;
#[path = "patch/diff.rs"]
mod diff; mod diff;
#[path = "patch/edit.rs"]
mod edit; mod edit;
#[path = "patch/label.rs"]
mod label; mod label;
#[path = "patch/list.rs"]
mod list; mod list;
#[path = "patch/react.rs"]
mod react; mod react;
#[path = "patch/ready.rs"]
mod ready; mod ready;
#[path = "patch/redact.rs"]
mod redact; mod redact;
#[path = "patch/resolve.rs"]
mod resolve; mod resolve;
#[path = "patch/review.rs"]
mod review; mod review;
#[path = "patch/show.rs"]
mod show; mod show;
#[path = "patch/update.rs"]
mod update; mod update;
use std::collections::BTreeSet; use std::collections::BTreeSet;

View File

@ -1,8 +1,5 @@
#[path = "comment/edit.rs"]
pub mod edit; pub mod edit;
#[path = "comment/react.rs"]
pub mod react; pub mod react;
#[path = "comment/redact.rs"]
pub mod redact; pub mod redact;
use super::*; use super::*;

View File

@ -1,4 +1,3 @@
#[path = "review/builder.rs"]
mod builder; mod builder;
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};

View File

@ -1,9 +1,7 @@
//! Remote Command implementation //! Remote Command implementation
#[path = "remote/add.rs"]
pub mod add; pub mod add;
#[path = "remote/list.rs"]
pub mod list; pub mod list;
#[path = "remote/rm.rs"]
pub mod rm; pub mod rm;
use std::ffi::OsString; use std::ffi::OsString;

View File

@ -6,9 +6,9 @@ use radicle::prelude::*;
use radicle::Profile; use radicle::Profile;
use radicle_crypto::PublicKey; use radicle_crypto::PublicKey;
use crate::commands::rad_checkout as checkout; use crate::commands::checkout;
use crate::commands::rad_follow as follow; use crate::commands::follow;
use crate::commands::rad_sync as sync; use crate::commands::sync;
use crate::node::SyncSettings; use crate::node::SyncSettings;
use crate::project::SetupRemote; use crate::project::SetupRemote;

View File

@ -11,7 +11,7 @@ use radicle::node::Handle;
use radicle::{prelude::*, Node}; use radicle::{prelude::*, Node};
use radicle_term::Element as _; use radicle_term::Element as _;
use crate::commands::rad_sync as sync; use crate::commands::sync;
use crate::node::SyncSettings; use crate::node::SyncSettings;
use crate::terminal as term; use crate::terminal as term;
use crate::terminal::args::{Args, Error, Help}; use crate::terminal::args::{Args, Error, Help};

View File

@ -100,7 +100,7 @@ fn print_help() -> anyhow::Result<()> {
println!("{DESCRIPTION}"); println!("{DESCRIPTION}");
println!(); println!();
rad_help::run(Default::default(), term::DefaultContext) help::run(Default::default(), term::DefaultContext)
} }
fn run(command: Command) -> Result<(), Option<anyhow::Error>> { fn run(command: Command) -> Result<(), Option<anyhow::Error>> {
@ -136,148 +136,82 @@ fn run(command: Command) -> Result<(), Option<anyhow::Error>> {
fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>> { fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>> {
match exe { match exe {
"auth" => { "auth" => {
term::run_command_args::<rad_auth::Options, _>( term::run_command_args::<auth::Options, _>(auth::HELP, auth::run, args.to_vec());
rad_auth::HELP,
rad_auth::run,
args.to_vec(),
);
} }
"block" => { "block" => {
term::run_command_args::<rad_block::Options, _>( term::run_command_args::<block::Options, _>(block::HELP, block::run, args.to_vec());
rad_block::HELP,
rad_block::run,
args.to_vec(),
);
} }
"checkout" => { "checkout" => {
term::run_command_args::<rad_checkout::Options, _>( term::run_command_args::<checkout::Options, _>(
rad_checkout::HELP, checkout::HELP,
rad_checkout::run, checkout::run,
args.to_vec(), args.to_vec(),
); );
} }
"clone" => { "clone" => {
term::run_command_args::<rad_clone::Options, _>( term::run_command_args::<clone::Options, _>(clone::HELP, clone::run, args.to_vec());
rad_clone::HELP,
rad_clone::run,
args.to_vec(),
);
} }
"cob" => { "cob" => {
term::run_command_args::<rad_cob::Options, _>( term::run_command_args::<cob::Options, _>(cob::HELP, cob::run, args.to_vec());
rad_cob::HELP,
rad_cob::run,
args.to_vec(),
);
} }
"config" => { "config" => {
term::run_command_args::<rad_config::Options, _>( term::run_command_args::<config::Options, _>(config::HELP, config::run, args.to_vec());
rad_config::HELP,
rad_config::run,
args.to_vec(),
);
} }
"diff" => { "diff" => {
term::run_command_args::<rad_diff::Options, _>( term::run_command_args::<diff::Options, _>(diff::HELP, diff::run, args.to_vec());
rad_diff::HELP,
rad_diff::run,
args.to_vec(),
);
} }
"debug" => { "debug" => {
term::run_command_args::<rad_debug::Options, _>( term::run_command_args::<debug::Options, _>(debug::HELP, debug::run, args.to_vec());
rad_debug::HELP,
rad_debug::run,
args.to_vec(),
);
} }
"follow" => { "follow" => {
term::run_command_args::<rad_follow::Options, _>( term::run_command_args::<follow::Options, _>(follow::HELP, follow::run, args.to_vec());
rad_follow::HELP,
rad_follow::run,
args.to_vec(),
);
} }
"fork" => { "fork" => {
term::run_command_args::<rad_fork::Options, _>( term::run_command_args::<fork::Options, _>(fork::HELP, fork::run, args.to_vec());
rad_fork::HELP,
rad_fork::run,
args.to_vec(),
);
} }
"help" => { "help" => {
term::run_command_args::<rad_help::Options, _>( term::run_command_args::<help::Options, _>(help::HELP, help::run, args.to_vec());
rad_help::HELP,
rad_help::run,
args.to_vec(),
);
} }
"id" => { "id" => {
term::run_command_args::<rad_id::Options, _>(rad_id::HELP, rad_id::run, args.to_vec()); term::run_command_args::<id::Options, _>(id::HELP, id::run, args.to_vec());
}
"inbox" => {
term::run_command_args::<inbox::Options, _>(inbox::HELP, inbox::run, args.to_vec())
} }
"inbox" => term::run_command_args::<rad_inbox::Options, _>(
rad_inbox::HELP,
rad_inbox::run,
args.to_vec(),
),
"init" => { "init" => {
term::run_command_args::<rad_init::Options, _>( term::run_command_args::<init::Options, _>(init::HELP, init::run, args.to_vec());
rad_init::HELP,
rad_init::run,
args.to_vec(),
);
} }
"inspect" => { "inspect" => {
term::run_command_args::<rad_inspect::Options, _>( term::run_command_args::<inspect::Options, _>(
rad_inspect::HELP, inspect::HELP,
rad_inspect::run, inspect::run,
args.to_vec(), args.to_vec(),
); );
} }
"issue" => { "issue" => {
term::run_command_args::<rad_issue::Options, _>( term::run_command_args::<issue::Options, _>(issue::HELP, issue::run, args.to_vec());
rad_issue::HELP,
rad_issue::run,
args.to_vec(),
);
} }
"ls" => { "ls" => {
term::run_command_args::<rad_ls::Options, _>(rad_ls::HELP, rad_ls::run, args.to_vec()); term::run_command_args::<ls::Options, _>(ls::HELP, ls::run, args.to_vec());
} }
"node" => { "node" => {
term::run_command_args::<rad_node::Options, _>( term::run_command_args::<node::Options, _>(node::HELP, node::run, args.to_vec());
rad_node::HELP,
rad_node::run,
args.to_vec(),
);
} }
"patch" => { "patch" => {
term::run_command_args::<rad_patch::Options, _>( term::run_command_args::<patch::Options, _>(patch::HELP, patch::run, args.to_vec());
rad_patch::HELP,
rad_patch::run,
args.to_vec(),
);
} }
"path" => { "path" => {
term::run_command_args::<rad_path::Options, _>( term::run_command_args::<path::Options, _>(path::HELP, path::run, args.to_vec());
rad_path::HELP,
rad_path::run,
args.to_vec(),
);
} }
"publish" => { "publish" => {
term::run_command_args::<rad_publish::Options, _>( term::run_command_args::<publish::Options, _>(
rad_publish::HELP, publish::HELP,
rad_publish::run, publish::run,
args.to_vec(), args.to_vec(),
); );
} }
"clean" => { "clean" => {
term::run_command_args::<rad_clean::Options, _>( term::run_command_args::<clean::Options, _>(clean::HELP, clean::run, args.to_vec());
rad_clean::HELP,
rad_clean::run,
args.to_vec(),
);
} }
"self" => { "self" => {
term::run_command_args::<rad_self::Options, _>( term::run_command_args::<rad_self::Options, _>(
@ -287,55 +221,37 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
); );
} }
"sync" => { "sync" => {
term::run_command_args::<rad_sync::Options, _>( term::run_command_args::<sync::Options, _>(sync::HELP, sync::run, args.to_vec());
rad_sync::HELP,
rad_sync::run,
args.to_vec(),
);
} }
"seed" => { "seed" => {
term::run_command_args::<rad_seed::Options, _>( term::run_command_args::<seed::Options, _>(seed::HELP, seed::run, args.to_vec());
rad_seed::HELP,
rad_seed::run,
args.to_vec(),
);
} }
"unblock" => { "unblock" => {
term::run_command_args::<rad_unblock::Options, _>( term::run_command_args::<unblock::Options, _>(
rad_unblock::HELP, unblock::HELP,
rad_unblock::run, unblock::run,
args.to_vec(), args.to_vec(),
); );
} }
"unfollow" => { "unfollow" => {
term::run_command_args::<rad_unfollow::Options, _>( term::run_command_args::<unfollow::Options, _>(
rad_unfollow::HELP, unfollow::HELP,
rad_unfollow::run, unfollow::run,
args.to_vec(), args.to_vec(),
); );
} }
"unseed" => { "unseed" => {
term::run_command_args::<rad_unseed::Options, _>( term::run_command_args::<unseed::Options, _>(unseed::HELP, unseed::run, args.to_vec());
rad_unseed::HELP, }
rad_unseed::run, "remote" => {
args.to_vec(), term::run_command_args::<remote::Options, _>(remote::HELP, remote::run, args.to_vec())
); }
"stats" => {
term::run_command_args::<stats::Options, _>(stats::HELP, stats::run, args.to_vec())
}
"watch" => {
term::run_command_args::<watch::Options, _>(watch::HELP, watch::run, args.to_vec())
} }
"remote" => term::run_command_args::<rad_remote::Options, _>(
rad_remote::HELP,
rad_remote::run,
args.to_vec(),
),
"stats" => term::run_command_args::<rad_stats::Options, _>(
rad_stats::HELP,
rad_stats::run,
args.to_vec(),
),
"watch" => term::run_command_args::<rad_watch::Options, _>(
rad_watch::HELP,
rad_watch::run,
args.to_vec(),
),
other => { other => {
let exe = format!("{NAME}-{exe}"); let exe = format!("{NAME}-{exe}");
let status = process::Command::new(exe).args(args).status(); let status = process::Command::new(exe).args(args).status();