Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
Rewrite how modules are declared
Merged did:key:z6MkwcUR...q1kL opened 8 months ago

This patchset rewrites how modules are declared (in radicle-cli, because this is the only crate that uses the… unconventional method of declaring modules).

The first patch cleans the thing up, the second patch deprecates the alternative module names. This one I think can be/should be discussed a bit more. I don’t want to just remove the alternative names with this patchset because that might break downstream - whoever that is… if it is only within this repository, lets go and just remove it! If external parties might be involved, we might wait for another release cycle?

The “self” module is a bit of a special case (included this also in the commit message), because self is a identifier in Rust, so it actually has to be rad_self here. Can we think of a better name for the whole module?

That is all, happy to see your review!

14 files changed +116 -260 11fc98c9 ff021d58
modified 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;
modified 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;
modified 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)]
modified 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(),
modified crates/radicle-cli/src/commands/issue.rs
@@ -1,4 +1,3 @@
-
#[path = "issue/cache.rs"]
mod cache;

use std::collections::BTreeSet;
modified 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 {
modified 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 _;

modified 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;
modified 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::*;
modified crates/radicle-cli/src/commands/patch/review.rs
@@ -1,4 +1,3 @@
-
#[path = "review/builder.rs"]
mod builder;

use anyhow::{anyhow, Context};
modified 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;
modified 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;

modified 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};
modified 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<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>> {
    match exe {
        "auth" => {
-
            term::run_command_args::<rad_auth::Options, _>(
-
                rad_auth::HELP,
-
                rad_auth::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<auth::Options, _>(auth::HELP, auth::run, args.to_vec());
        }
        "block" => {
-
            term::run_command_args::<rad_block::Options, _>(
-
                rad_block::HELP,
-
                rad_block::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<block::Options, _>(block::HELP, block::run, args.to_vec());
        }
        "checkout" => {
-
            term::run_command_args::<rad_checkout::Options, _>(
-
                rad_checkout::HELP,
-
                rad_checkout::run,
+
            term::run_command_args::<checkout::Options, _>(
+
                checkout::HELP,
+
                checkout::run,
                args.to_vec(),
            );
        }
        "clone" => {
-
            term::run_command_args::<rad_clone::Options, _>(
-
                rad_clone::HELP,
-
                rad_clone::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<clone::Options, _>(clone::HELP, clone::run, args.to_vec());
        }
        "cob" => {
-
            term::run_command_args::<rad_cob::Options, _>(
-
                rad_cob::HELP,
-
                rad_cob::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<cob::Options, _>(cob::HELP, cob::run, args.to_vec());
        }
        "config" => {
-
            term::run_command_args::<rad_config::Options, _>(
-
                rad_config::HELP,
-
                rad_config::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<config::Options, _>(config::HELP, config::run, args.to_vec());
        }
        "diff" => {
-
            term::run_command_args::<rad_diff::Options, _>(
-
                rad_diff::HELP,
-
                rad_diff::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<diff::Options, _>(diff::HELP, diff::run, args.to_vec());
        }
        "debug" => {
-
            term::run_command_args::<rad_debug::Options, _>(
-
                rad_debug::HELP,
-
                rad_debug::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<debug::Options, _>(debug::HELP, debug::run, args.to_vec());
        }
        "follow" => {
-
            term::run_command_args::<rad_follow::Options, _>(
-
                rad_follow::HELP,
-
                rad_follow::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<follow::Options, _>(follow::HELP, follow::run, args.to_vec());
        }
        "fork" => {
-
            term::run_command_args::<rad_fork::Options, _>(
-
                rad_fork::HELP,
-
                rad_fork::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<fork::Options, _>(fork::HELP, fork::run, args.to_vec());
        }
        "help" => {
-
            term::run_command_args::<rad_help::Options, _>(
-
                rad_help::HELP,
-
                rad_help::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<help::Options, _>(help::HELP, help::run, args.to_vec());
        }
        "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" => {
-
            term::run_command_args::<rad_init::Options, _>(
-
                rad_init::HELP,
-
                rad_init::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<init::Options, _>(init::HELP, init::run, args.to_vec());
        }
        "inspect" => {
-
            term::run_command_args::<rad_inspect::Options, _>(
-
                rad_inspect::HELP,
-
                rad_inspect::run,
+
            term::run_command_args::<inspect::Options, _>(
+
                inspect::HELP,
+
                inspect::run,
                args.to_vec(),
            );
        }
        "issue" => {
-
            term::run_command_args::<rad_issue::Options, _>(
-
                rad_issue::HELP,
-
                rad_issue::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<issue::Options, _>(issue::HELP, issue::run, args.to_vec());
        }
        "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" => {
-
            term::run_command_args::<rad_node::Options, _>(
-
                rad_node::HELP,
-
                rad_node::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<node::Options, _>(node::HELP, node::run, args.to_vec());
        }
        "patch" => {
-
            term::run_command_args::<rad_patch::Options, _>(
-
                rad_patch::HELP,
-
                rad_patch::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<patch::Options, _>(patch::HELP, patch::run, args.to_vec());
        }
        "path" => {
-
            term::run_command_args::<rad_path::Options, _>(
-
                rad_path::HELP,
-
                rad_path::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<path::Options, _>(path::HELP, path::run, args.to_vec());
        }
        "publish" => {
-
            term::run_command_args::<rad_publish::Options, _>(
-
                rad_publish::HELP,
-
                rad_publish::run,
+
            term::run_command_args::<publish::Options, _>(
+
                publish::HELP,
+
                publish::run,
                args.to_vec(),
            );
        }
        "clean" => {
-
            term::run_command_args::<rad_clean::Options, _>(
-
                rad_clean::HELP,
-
                rad_clean::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<clean::Options, _>(clean::HELP, clean::run, args.to_vec());
        }
        "self" => {
            term::run_command_args::<rad_self::Options, _>(
@@ -287,55 +221,37 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
            );
        }
        "sync" => {
-
            term::run_command_args::<rad_sync::Options, _>(
-
                rad_sync::HELP,
-
                rad_sync::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<sync::Options, _>(sync::HELP, sync::run, args.to_vec());
        }
        "seed" => {
-
            term::run_command_args::<rad_seed::Options, _>(
-
                rad_seed::HELP,
-
                rad_seed::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<seed::Options, _>(seed::HELP, seed::run, args.to_vec());
        }
        "unblock" => {
-
            term::run_command_args::<rad_unblock::Options, _>(
-
                rad_unblock::HELP,
-
                rad_unblock::run,
+
            term::run_command_args::<unblock::Options, _>(
+
                unblock::HELP,
+
                unblock::run,
                args.to_vec(),
            );
        }
        "unfollow" => {
-
            term::run_command_args::<rad_unfollow::Options, _>(
-
                rad_unfollow::HELP,
-
                rad_unfollow::run,
+
            term::run_command_args::<unfollow::Options, _>(
+
                unfollow::HELP,
+
                unfollow::run,
                args.to_vec(),
            );
        }
        "unseed" => {
-
            term::run_command_args::<rad_unseed::Options, _>(
-
                rad_unseed::HELP,
-
                rad_unseed::run,
-
                args.to_vec(),
-
            );
+
            term::run_command_args::<unseed::Options, _>(unseed::HELP, unseed::run, args.to_vec());
+
        }
+
        "remote" => {
+
            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 => {
            let exe = format!("{NAME}-{exe}");
            let status = process::Command::new(exe).args(args).status();