diff --git a/crates/radicle-cli/src/commands.rs b/crates/radicle-cli/src/commands.rs index 0fcfb49e..7995a39a 100644 --- a/crates/radicle-cli/src/commands.rs +++ b/crates/radicle-cli/src/commands.rs @@ -9,7 +9,6 @@ pub mod debug; pub mod diff; pub mod follow; pub mod fork; -pub mod help; pub mod id; pub mod inbox; pub mod init; diff --git a/crates/radicle-cli/src/commands/auth.rs b/crates/radicle-cli/src/commands/auth.rs index 253c3b8e..100b9a96 100644 --- a/crates/radicle-cli/src/commands/auth.rs +++ b/crates/radicle-cli/src/commands/auth.rs @@ -14,7 +14,6 @@ use radicle::{profile, Profile}; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { match ctx.profile() { diff --git a/crates/radicle-cli/src/commands/auth/args.rs b/crates/radicle-cli/src/commands/auth/args.rs index 3c693e63..94944ba6 100644 --- a/crates/radicle-cli/src/commands/auth/args.rs +++ b/crates/radicle-cli/src/commands/auth/args.rs @@ -1,7 +1,7 @@ use clap::Parser; use radicle::node::Alias; -pub(crate) const ABOUT: &str = "Manage identities and profiles"; +const ABOUT: &str = "Manage identities and profiles"; const LONG_ABOUT: &str = r#" A passphrase may be given via the environment variable `RAD_PASSPHRASE` or via the standard input stream if `--stdin` is used. Using either of these diff --git a/crates/radicle-cli/src/commands/block.rs b/crates/radicle-cli/src/commands/block.rs index a1ad057a..f9786da4 100644 --- a/crates/radicle-cli/src/commands/block.rs +++ b/crates/radicle-cli/src/commands/block.rs @@ -7,7 +7,6 @@ use crate::terminal as term; use term::args::BlockTarget; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/block/args.rs b/crates/radicle-cli/src/commands/block/args.rs index 1491f382..f75cdcd3 100644 --- a/crates/radicle-cli/src/commands/block/args.rs +++ b/crates/radicle-cli/src/commands/block/args.rs @@ -2,7 +2,7 @@ use clap::Parser; use crate::terminal::args::BlockTarget; -pub(crate) const ABOUT: &str = "Block repositories or nodes from being seeded or followed"; +const ABOUT: &str = "Block repositories or nodes from being seeded or followed"; #[derive(Parser, Debug)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/checkout.rs b/crates/radicle-cli/src/commands/checkout.rs index 190984ed..9cc7a4dd 100644 --- a/crates/radicle-cli/src/commands/checkout.rs +++ b/crates/radicle-cli/src/commands/checkout.rs @@ -15,7 +15,6 @@ use crate::project; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/checkout/args.rs b/crates/radicle-cli/src/commands/checkout/args.rs index 95788647..f6654ad2 100644 --- a/crates/radicle-cli/src/commands/checkout/args.rs +++ b/crates/radicle-cli/src/commands/checkout/args.rs @@ -1,7 +1,7 @@ use clap::Parser; use radicle::prelude::{Did, RepoId}; -pub(crate) const ABOUT: &str = "Checkout a repository into the local directory"; +const ABOUT: &str = "Checkout a repository into the local directory"; const LONG_ABOUT: &str = r#" Creates a working copy from a repository in local storage. "#; diff --git a/crates/radicle-cli/src/commands/clean.rs b/crates/radicle-cli/src/commands/clean.rs index 08771743..4452085c 100644 --- a/crates/radicle-cli/src/commands/clean.rs +++ b/crates/radicle-cli/src/commands/clean.rs @@ -6,7 +6,6 @@ use radicle::storage::WriteStorage; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/clean/args.rs b/crates/radicle-cli/src/commands/clean/args.rs index c2175006..fc836ae4 100644 --- a/crates/radicle-cli/src/commands/clean/args.rs +++ b/crates/radicle-cli/src/commands/clean/args.rs @@ -2,7 +2,7 @@ use clap::Parser; use radicle::prelude::RepoId; -pub const ABOUT: &str = "Remove all remotes from a repository"; +const ABOUT: &str = "Remove all remotes from a repository"; const LONG_ABOUT: &str = r#" Removes all remotes from a repository, as long as they are not the diff --git a/crates/radicle-cli/src/commands/clone.rs b/crates/radicle-cli/src/commands/clone.rs index 1e6b48ff..f90a77df 100644 --- a/crates/radicle-cli/src/commands/clone.rs +++ b/crates/radicle-cli/src/commands/clone.rs @@ -26,7 +26,6 @@ use crate::terminal as term; use crate::terminal::Element as _; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/clone/args.rs b/crates/radicle-cli/src/commands/clone/args.rs index 0d92d7b4..0c763bfe 100644 --- a/crates/radicle-cli/src/commands/clone/args.rs +++ b/crates/radicle-cli/src/commands/clone/args.rs @@ -11,7 +11,7 @@ use radicle::prelude::*; use crate::terminal; -pub(crate) const ABOUT: &str = "Clone a Radicle repository"; +const ABOUT: &str = "Clone a Radicle repository"; const LONG_ABOUT: &str = r#" The `clone` command will use your local node's routing table to find seeds from diff --git a/crates/radicle-cli/src/commands/config.rs b/crates/radicle-cli/src/commands/config.rs index 8b8f8f79..a74c8409 100644 --- a/crates/radicle-cli/src/commands/config.rs +++ b/crates/radicle-cli/src/commands/config.rs @@ -2,7 +2,6 @@ mod args; pub use args::Args; use args::Command; -pub(crate) use args::ABOUT; use std::path::Path; diff --git a/crates/radicle-cli/src/commands/config/args.rs b/crates/radicle-cli/src/commands/config/args.rs index 9b69ad00..c80a97ff 100644 --- a/crates/radicle-cli/src/commands/config/args.rs +++ b/crates/radicle-cli/src/commands/config/args.rs @@ -1,7 +1,7 @@ use clap::{Parser, Subcommand}; use radicle::node::Alias; -pub(crate) const ABOUT: &str = "Manage your local Radicle configuration"; +const ABOUT: &str = "Manage your local Radicle configuration"; const LONG_ABOUT: &str = r#" If no argument is specified, prints the current radicle configuration as JSON. diff --git a/crates/radicle-cli/src/commands/debug.rs b/crates/radicle-cli/src/commands/debug.rs index 0d47bb0d..da8d1dae 100644 --- a/crates/radicle-cli/src/commands/debug.rs +++ b/crates/radicle-cli/src/commands/debug.rs @@ -13,7 +13,6 @@ use radicle::Profile; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub const NAME: &str = "rad"; pub const VERSION: &str = env!("RADICLE_VERSION"); diff --git a/crates/radicle-cli/src/commands/debug/args.rs b/crates/radicle-cli/src/commands/debug/args.rs index b2fabc97..d5f8a57e 100644 --- a/crates/radicle-cli/src/commands/debug/args.rs +++ b/crates/radicle-cli/src/commands/debug/args.rs @@ -1,6 +1,6 @@ use clap::Parser; -pub const ABOUT: &str = "Write out information to help debug your Radicle node remotely"; +const ABOUT: &str = "Write out information to help debug your Radicle node remotely"; const LONG_ABOUT: &str = r#" Run this if you are reporting a problem in Radicle. The output is diff --git a/crates/radicle-cli/src/commands/follow.rs b/crates/radicle-cli/src/commands/follow.rs index c1fc0ad0..851542c1 100644 --- a/crates/radicle-cli/src/commands/follow.rs +++ b/crates/radicle-cli/src/commands/follow.rs @@ -8,7 +8,6 @@ use crate::terminal as term; pub use args::Args; use args::Operation; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/follow/args.rs b/crates/radicle-cli/src/commands/follow/args.rs index 7b1e4a69..35860f5c 100644 --- a/crates/radicle-cli/src/commands/follow/args.rs +++ b/crates/radicle-cli/src/commands/follow/args.rs @@ -4,7 +4,7 @@ use radicle::node::{Alias, NodeId}; use crate::terminal as term; -pub(crate) const ABOUT: &str = "Manage node follow policies"; +const ABOUT: &str = "Manage node follow policies"; const LONG_ABOUT: &str = r#" The `follow` command will print all nodes being followed, optionally filtered by alias, if no diff --git a/crates/radicle-cli/src/commands/fork.rs b/crates/radicle-cli/src/commands/fork.rs index 7a54f342..2ca236f3 100644 --- a/crates/radicle-cli/src/commands/fork.rs +++ b/crates/radicle-cli/src/commands/fork.rs @@ -7,7 +7,6 @@ use radicle::rad; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/fork/args.rs b/crates/radicle-cli/src/commands/fork/args.rs index 77a2b7b3..9c195548 100644 --- a/crates/radicle-cli/src/commands/fork/args.rs +++ b/crates/radicle-cli/src/commands/fork/args.rs @@ -1,6 +1,6 @@ use radicle::identity::RepoId; -pub(crate) const ABOUT: &str = "Create a fork of a repository"; +const ABOUT: &str = "Create a fork of a repository"; #[derive(Debug, clap::Parser)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/help.rs b/crates/radicle-cli/src/commands/help.rs deleted file mode 100644 index db6ca2e3..00000000 --- a/crates/radicle-cli/src/commands/help.rs +++ /dev/null @@ -1,213 +0,0 @@ -use std::ffi::OsString; - -use crate::terminal as term; -use crate::terminal::args::{Args, Error, Help}; - -pub const HELP: Help = Help { - name: "help", - description: "CLI help", - version: env!("RADICLE_VERSION"), - usage: "Usage: rad help [--help]", -}; - -enum CommandItem { - Lexopt(Help), - Clap { - name: &'static str, - about: &'static str, - }, -} - -impl CommandItem { - fn name(&self) -> &str { - match self { - CommandItem::Lexopt(help) => help.name, - CommandItem::Clap { name, .. } => name, - } - } - - fn description(&self) -> &str { - match self { - CommandItem::Lexopt(help) => help.description, - CommandItem::Clap { - about: description, .. - } => description, - } - } -} - -const COMMANDS: &[CommandItem] = &[ - CommandItem::Clap { - name: "auth", - about: crate::commands::auth::ABOUT, - }, - CommandItem::Clap { - name: "block", - about: crate::commands::block::ABOUT, - }, - CommandItem::Clap { - name: "checkout", - about: crate::commands::checkout::ABOUT, - }, - CommandItem::Clap { - name: "clone", - about: crate::commands::clone::ABOUT, - }, - CommandItem::Clap { - name: "config", - about: crate::commands::config::ABOUT, - }, - CommandItem::Clap { - name: "debug", - about: crate::commands::debug::ABOUT, - }, - CommandItem::Clap { - name: "fork", - about: crate::commands::fork::ABOUT, - }, - CommandItem::Lexopt(crate::commands::help::HELP), - CommandItem::Clap { - name: "id", - about: crate::commands::id::ABOUT, - }, - CommandItem::Clap { - name: "init", - about: crate::commands::init::ABOUT, - }, - CommandItem::Clap { - name: "inbox", - about: crate::commands::inbox::ABOUT, - }, - CommandItem::Clap { - name: "inspect", - about: crate::commands::inspect::ABOUT, - }, - CommandItem::Clap { - name: "issue", - about: crate::commands::issue::ABOUT, - }, - CommandItem::Clap { - name: "ls", - about: crate::commands::ls::ABOUT, - }, - CommandItem::Clap { - name: "node", - about: crate::commands::node::ABOUT, - }, - CommandItem::Clap { - name: "patch", - about: crate::commands::patch::ABOUT, - }, - CommandItem::Clap { - name: "path", - about: crate::commands::path::ABOUT, - }, - CommandItem::Clap { - name: "publish", - about: crate::commands::publish::ABOUT, - }, - CommandItem::Clap { - name: "clean", - about: crate::commands::clean::ABOUT, - }, - CommandItem::Clap { - name: "self", - about: crate::commands::rad_self::ABOUT, - }, - CommandItem::Clap { - name: "seed", - about: crate::commands::seed::ABOUT, - }, - CommandItem::Clap { - name: "follow", - about: crate::commands::follow::ABOUT, - }, - CommandItem::Clap { - name: "unblock", - about: crate::commands::unblock::ABOUT, - }, - CommandItem::Clap { - name: "unfollow", - about: crate::commands::unfollow::ABOUT, - }, - CommandItem::Clap { - name: "unseed", - about: crate::commands::unseed::ABOUT, - }, - CommandItem::Clap { - name: "remote", - about: crate::commands::remote::ABOUT, - }, - CommandItem::Clap { - name: "stats", - about: crate::commands::stats::ABOUT, - }, - CommandItem::Clap { - name: "sync", - about: crate::commands::sync::ABOUT, - }, - CommandItem::Clap { - name: "watch", - about: crate::commands::watch::ABOUT, - }, -]; - -#[derive(Default)] -pub struct Options {} - -impl Args for Options { - fn from_args(args: Vec) -> anyhow::Result<(Self, Vec)> { - let mut parser = lexopt::Parser::from_args(args); - - if let Some(arg) = parser.next()? { - anyhow::bail!(arg.unexpected()); - } - Err(Error::HelpManual { name: "rad" }.into()) - } -} - -pub fn run(_options: Options, ctx: impl term::Context) -> anyhow::Result<()> { - term::print("Usage: rad [--help]"); - - if let Err(e) = ctx.profile() { - term::blank(); - match e.downcast_ref() { - Some(term::args::Error::WithHint { err, hint }) => { - term::print(term::format::yellow(err)); - term::print(term::format::yellow(hint)); - } - Some(e) => { - term::error(e); - } - None => { - term::error(e); - } - } - term::blank(); - } - - term::print("Common `rad` commands used in various situations:"); - term::blank(); - - for help in COMMANDS { - term::info!( - "\t{} {}", - term::format::bold(format!("{:-12}", help.name())), - term::format::dim(help.description()) - ); - } - term::blank(); - term::print("See `rad --help` to learn about a specific command."); - term::blank(); - - term::print("Do you have feedback?"); - term::print( - " - Chat <\x1b]8;;https://radicle.zulipchat.com\x1b\\radicle.zulipchat.com\x1b]8;;\x1b\\>", - ); - term::print( - " - Mail <\x1b]8;;mailto:feedback@radicle.xyz\x1b\\feedback@radicle.xyz\x1b]8;;\x1b\\>", - ); - term::print(" (Messages are automatically posted to the public #feedback channel on Zulip.)"); - - Ok(()) -} diff --git a/crates/radicle-cli/src/commands/id.rs b/crates/radicle-cli/src/commands/id.rs index 34bcad08..6bc9abbd 100644 --- a/crates/radicle-cli/src/commands/id.rs +++ b/crates/radicle-cli/src/commands/id.rs @@ -23,7 +23,6 @@ use crate::terminal::patch::Message; pub use args::Args; use args::Command; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/id/args.rs b/crates/radicle-cli/src/commands/id/args.rs index 251a93cc..05b802b7 100644 --- a/crates/radicle-cli/src/commands/id/args.rs +++ b/crates/radicle-cli/src/commands/id/args.rs @@ -17,7 +17,7 @@ use crate::git::Rev; use crate::terminal::Interactive; -pub(crate) const ABOUT: &str = "Manage repository identities"; +const ABOUT: &str = "Manage repository identities"; const LONG_ABOUT: &str = r#" The `id` command is used to manage and propose changes to the identity of a Radicle repository. diff --git a/crates/radicle-cli/src/commands/inbox.rs b/crates/radicle-cli/src/commands/inbox.rs index bd021518..7dd3ddbc 100644 --- a/crates/radicle-cli/src/commands/inbox.rs +++ b/crates/radicle-cli/src/commands/inbox.rs @@ -1,7 +1,6 @@ mod args; pub use args::Args; -pub(crate) use args::ABOUT; use std::path::Path; use std::process; diff --git a/crates/radicle-cli/src/commands/inbox/args.rs b/crates/radicle-cli/src/commands/inbox/args.rs index b45bab36..28de59aa 100644 --- a/crates/radicle-cli/src/commands/inbox/args.rs +++ b/crates/radicle-cli/src/commands/inbox/args.rs @@ -3,7 +3,7 @@ use std::{fmt::Display, str::FromStr}; use clap::{Parser, Subcommand, ValueEnum}; use radicle::{node::notifications::NotificationId, prelude::RepoId}; -pub(crate) const ABOUT: &str = "Manage your Radicle notifications"; +const ABOUT: &str = "Manage your Radicle notifications"; const LONG_ABOUT: &str = r#" By default, this command lists all items in your inbox. diff --git a/crates/radicle-cli/src/commands/init.rs b/crates/radicle-cli/src/commands/init.rs index d44ea66a..c81f642b 100644 --- a/crates/radicle-cli/src/commands/init.rs +++ b/crates/radicle-cli/src/commands/init.rs @@ -4,7 +4,6 @@ mod args; pub use args::Args; -pub(crate) use args::ABOUT; use std::collections::HashSet; use std::convert::TryFrom; diff --git a/crates/radicle-cli/src/commands/init/args.rs b/crates/radicle-cli/src/commands/init/args.rs index 07a5eaf7..d45e3268 100644 --- a/crates/radicle-cli/src/commands/init/args.rs +++ b/crates/radicle-cli/src/commands/init/args.rs @@ -8,7 +8,7 @@ use radicle::{ }; use radicle_term::Interactive; -pub(crate) const ABOUT: &str = "Initialize a Radicle repository"; +const ABOUT: &str = "Initialize a Radicle repository"; #[derive(Debug, Parser)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/inspect.rs b/crates/radicle-cli/src/commands/inspect.rs index 018f594b..9d4fed30 100644 --- a/crates/radicle-cli/src/commands/inspect.rs +++ b/crates/radicle-cli/src/commands/inspect.rs @@ -23,7 +23,6 @@ use crate::terminal::Element; pub use args::Args; use args::Target; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let rid = match args.repo { diff --git a/crates/radicle-cli/src/commands/inspect/args.rs b/crates/radicle-cli/src/commands/inspect/args.rs index d79bf0f2..e849daf9 100644 --- a/crates/radicle-cli/src/commands/inspect/args.rs +++ b/crates/radicle-cli/src/commands/inspect/args.rs @@ -1,6 +1,6 @@ use clap::Parser; -pub(crate) const ABOUT: &str = "Inspect a Radicle repository"; +const ABOUT: &str = "Inspect a Radicle repository"; const LONG_ABOUT: &str = r#"Inspects the given path or RID. If neither is specified, the current repository is inspected. "#; diff --git a/crates/radicle-cli/src/commands/issue.rs b/crates/radicle-cli/src/commands/issue.rs index fb7aec7d..24a28415 100644 --- a/crates/radicle-cli/src/commands/issue.rs +++ b/crates/radicle-cli/src/commands/issue.rs @@ -30,7 +30,7 @@ use crate::terminal::format::Author; use crate::terminal::issue::Format; use crate::terminal::Element; -pub(crate) const ABOUT: &str = "Manage issues"; +const ABOUT: &str = "Manage issues"; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/ls.rs b/crates/radicle-cli/src/commands/ls.rs index 5260d857..387f4c81 100644 --- a/crates/radicle-cli/src/commands/ls.rs +++ b/crates/radicle-cli/src/commands/ls.rs @@ -1,7 +1,6 @@ mod args; pub use args::Args; -pub(crate) use args::ABOUT; use radicle::storage::{ReadStorage, RepositoryInfo}; diff --git a/crates/radicle-cli/src/commands/ls/args.rs b/crates/radicle-cli/src/commands/ls/args.rs index cb69df78..333db742 100644 --- a/crates/radicle-cli/src/commands/ls/args.rs +++ b/crates/radicle-cli/src/commands/ls/args.rs @@ -1,6 +1,6 @@ use clap::Parser; -pub(crate) const ABOUT: &str = "List repositories"; +const ABOUT: &str = "List repositories"; const LONG_ABOUT: &str = r#" By default, this command shows you all repositories that you have forked or initialized. If you wish to see all seeded repositories, use the `--seeded` option. diff --git a/crates/radicle-cli/src/commands/node.rs b/crates/radicle-cli/src/commands/node.rs index 7a05e177..2d901df3 100644 --- a/crates/radicle-cli/src/commands/node.rs +++ b/crates/radicle-cli/src/commands/node.rs @@ -19,7 +19,6 @@ use crate::terminal::Element as _; use crate::warning; pub use args::Args; -pub(crate) use args::ABOUT; use args::{Addr, Command}; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { diff --git a/crates/radicle-cli/src/commands/node/args.rs b/crates/radicle-cli/src/commands/node/args.rs index 7bcd590f..db1f025b 100644 --- a/crates/radicle-cli/src/commands/node/args.rs +++ b/crates/radicle-cli/src/commands/node/args.rs @@ -11,7 +11,7 @@ use radicle::crypto::{PublicKey, PublicKeyError}; use radicle::node::{Address, NodeId, PeerAddr, PeerAddrParseError}; use radicle::prelude::RepoId; -pub(crate) const ABOUT: &str = "Control and query the Radicle Node"; +const ABOUT: &str = "Control and query the Radicle Node"; #[derive(Parser, Debug)] #[command(about = ABOUT, long_about, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/patch.rs b/crates/radicle-cli/src/commands/patch.rs index 20a3f77f..c7666712 100644 --- a/crates/radicle-cli/src/commands/patch.rs +++ b/crates/radicle-cli/src/commands/patch.rs @@ -33,7 +33,6 @@ use crate::terminal as term; use crate::terminal::patch::Message; pub use args::Args; -pub(crate) use args::ABOUT; use args::{AssignArgs, Command, CommentAction, LabelArgs}; diff --git a/crates/radicle-cli/src/commands/patch/args.rs b/crates/radicle-cli/src/commands/patch/args.rs index 5125740e..1d0ac156 100644 --- a/crates/radicle-cli/src/commands/patch/args.rs +++ b/crates/radicle-cli/src/commands/patch/args.rs @@ -14,7 +14,7 @@ use crate::commands::patch::review; use crate::git::Rev; use crate::terminal::patch::Message; -pub(crate) const ABOUT: &str = "Manage patches"; +const ABOUT: &str = "Manage patches"; #[derive(Debug, Parser)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/path.rs b/crates/radicle-cli/src/commands/path.rs index cddac86f..d5ab589b 100644 --- a/crates/radicle-cli/src/commands/path.rs +++ b/crates/radicle-cli/src/commands/path.rs @@ -5,7 +5,6 @@ use radicle::profile; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(_args: Args, _ctx: impl term::Context) -> anyhow::Result<()> { let home = profile::home()?; diff --git a/crates/radicle-cli/src/commands/path/args.rs b/crates/radicle-cli/src/commands/path/args.rs index 58ea1b6d..81e60d02 100644 --- a/crates/radicle-cli/src/commands/path/args.rs +++ b/crates/radicle-cli/src/commands/path/args.rs @@ -1,6 +1,6 @@ use clap::Parser; -pub const ABOUT: &str = "Display the Radicle home path"; +const ABOUT: &str = "Display the Radicle home path"; #[derive(Parser, Debug)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/publish.rs b/crates/radicle-cli/src/commands/publish.rs index 47b522f5..e2ac9f10 100644 --- a/crates/radicle-cli/src/commands/publish.rs +++ b/crates/radicle-cli/src/commands/publish.rs @@ -10,7 +10,6 @@ use radicle::storage::{SignRepository, ValidateRepository, WriteRepository, Writ use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/publish/args.rs b/crates/radicle-cli/src/commands/publish/args.rs index a05e49ae..ee0385af 100644 --- a/crates/radicle-cli/src/commands/publish/args.rs +++ b/crates/radicle-cli/src/commands/publish/args.rs @@ -1,6 +1,6 @@ use radicle::identity::RepoId; -pub(crate) const ABOUT: &str = "Publish a repository to the network"; +const ABOUT: &str = "Publish a repository to the network"; const LONG_ABOUT: &str = r#" Publishing a private repository makes it public and discoverable diff --git a/crates/radicle-cli/src/commands/remote.rs b/crates/radicle-cli/src/commands/remote.rs index 16013bba..61c59ecb 100644 --- a/crates/radicle-cli/src/commands/remote.rs +++ b/crates/radicle-cli/src/commands/remote.rs @@ -14,7 +14,6 @@ use crate::terminal as term; use crate::terminal::Context; pub use args::Args; -pub(crate) use args::ABOUT; use args::{Command, ListOption}; pub fn run(args: Args, ctx: impl Context) -> anyhow::Result<()> { diff --git a/crates/radicle-cli/src/commands/remote/args.rs b/crates/radicle-cli/src/commands/remote/args.rs index 69871851..19d70d68 100644 --- a/crates/radicle-cli/src/commands/remote/args.rs +++ b/crates/radicle-cli/src/commands/remote/args.rs @@ -6,7 +6,7 @@ use radicle::node::NodeId; use crate::terminal as term; -pub(crate) const ABOUT: &str = "Manage a repository's remotes"; +const ABOUT: &str = "Manage a repository's remotes"; #[derive(Parser, Debug)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/seed.rs b/crates/radicle-cli/src/commands/seed.rs index 4e2759ca..7482a835 100644 --- a/crates/radicle-cli/src/commands/seed.rs +++ b/crates/radicle-cli/src/commands/seed.rs @@ -10,7 +10,6 @@ use crate::commands::sync; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/seed/args.rs b/crates/radicle-cli/src/commands/seed/args.rs index c2bccbde..e654d1c2 100644 --- a/crates/radicle-cli/src/commands/seed/args.rs +++ b/crates/radicle-cli/src/commands/seed/args.rs @@ -9,7 +9,7 @@ use radicle::prelude::*; use crate::node::SyncSettings; use crate::terminal; -pub(crate) const ABOUT: &str = "Manage repository seeding policies"; +const ABOUT: &str = "Manage repository seeding policies"; const LONG_ABOUT: &str = r#" The `seed` command, when no Repository ID is provided, will list the diff --git a/crates/radicle-cli/src/commands/self.rs b/crates/radicle-cli/src/commands/self.rs index bf587c1e..1feb12f5 100644 --- a/crates/radicle-cli/src/commands/self.rs +++ b/crates/radicle-cli/src/commands/self.rs @@ -2,7 +2,6 @@ mod args; pub use args::Args; -pub(crate) use args::ABOUT; use radicle::crypto::ssh; use radicle::node::Handle as _; diff --git a/crates/radicle-cli/src/commands/self/args.rs b/crates/radicle-cli/src/commands/self/args.rs index 791d14eb..f4c9c8cb 100644 --- a/crates/radicle-cli/src/commands/self/args.rs +++ b/crates/radicle-cli/src/commands/self/args.rs @@ -1,6 +1,6 @@ use clap::Parser; -pub(crate) const ABOUT: &str = "Show information about your identity and device"; +const ABOUT: &str = "Show information about your identity and device"; #[derive(Debug, Parser)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/stats.rs b/crates/radicle-cli/src/commands/stats.rs index 386cee66..0465c601 100644 --- a/crates/radicle-cli/src/commands/stats.rs +++ b/crates/radicle-cli/src/commands/stats.rs @@ -16,7 +16,6 @@ use serde::Serialize; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; #[derive(Default, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/crates/radicle-cli/src/commands/stats/args.rs b/crates/radicle-cli/src/commands/stats/args.rs index 4a510105..e5039892 100644 --- a/crates/radicle-cli/src/commands/stats/args.rs +++ b/crates/radicle-cli/src/commands/stats/args.rs @@ -1,6 +1,6 @@ use clap::Parser; -pub(crate) const ABOUT: &str = "Displays aggregated repository and node metrics"; +const ABOUT: &str = "Displays aggregated repository and node metrics"; #[derive(Debug, Parser)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/sync.rs b/crates/radicle-cli/src/commands/sync.rs index 14a6eab1..8e881827 100644 --- a/crates/radicle-cli/src/commands/sync.rs +++ b/crates/radicle-cli/src/commands/sync.rs @@ -26,7 +26,6 @@ use crate::terminal::format::Author; use crate::terminal::{Table, TableOptions}; pub use args::Args; -pub(crate) use args::ABOUT; use args::{Command, SortBy, SyncDirection, SyncMode}; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { diff --git a/crates/radicle-cli/src/commands/sync/args.rs b/crates/radicle-cli/src/commands/sync/args.rs index ec398c90..ee4a02f1 100644 --- a/crates/radicle-cli/src/commands/sync/args.rs +++ b/crates/radicle-cli/src/commands/sync/args.rs @@ -10,7 +10,7 @@ use radicle::{ use crate::node::SyncSettings; -pub(crate) const ABOUT: &str = "Sync repositories to the network"; +const ABOUT: &str = "Sync repositories to the network"; const LONG_ABOUT: &str = r#" By default, the current repository is synchronized both ways. diff --git a/crates/radicle-cli/src/commands/unblock.rs b/crates/radicle-cli/src/commands/unblock.rs index 06160a58..e65b75f2 100644 --- a/crates/radicle-cli/src/commands/unblock.rs +++ b/crates/radicle-cli/src/commands/unblock.rs @@ -5,7 +5,6 @@ use crate::terminal as term; use term::args::BlockTarget; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/unblock/args.rs b/crates/radicle-cli/src/commands/unblock/args.rs index 02bc347b..635e8d67 100644 --- a/crates/radicle-cli/src/commands/unblock/args.rs +++ b/crates/radicle-cli/src/commands/unblock/args.rs @@ -2,8 +2,7 @@ use clap::Parser; use crate::terminal::args::BlockTarget; -pub(crate) const ABOUT: &str = - "Unblock repositories or nodes to allow them to be seeded or followed"; +const ABOUT: &str = "Unblock repositories or nodes to allow them to be seeded or followed"; #[derive(Parser, Debug)] #[command(about = ABOUT, disable_version_flag = true)] diff --git a/crates/radicle-cli/src/commands/unfollow.rs b/crates/radicle-cli/src/commands/unfollow.rs index 367b02b3..9e18555d 100644 --- a/crates/radicle-cli/src/commands/unfollow.rs +++ b/crates/radicle-cli/src/commands/unfollow.rs @@ -5,7 +5,6 @@ use radicle::node::Handle; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/unfollow/args.rs b/crates/radicle-cli/src/commands/unfollow/args.rs index 75a24597..57725575 100644 --- a/crates/radicle-cli/src/commands/unfollow/args.rs +++ b/crates/radicle-cli/src/commands/unfollow/args.rs @@ -4,7 +4,7 @@ use radicle::node::NodeId; use crate::terminal as term; -pub(crate) const ABOUT: &str = "Unfollow a peer"; +const ABOUT: &str = "Unfollow a peer"; const LONG_ABOUT: &str = r#" The `unfollow` command takes a Node ID, optionally in DID format, diff --git a/crates/radicle-cli/src/commands/unseed.rs b/crates/radicle-cli/src/commands/unseed.rs index 0a59c361..9bac3781 100644 --- a/crates/radicle-cli/src/commands/unseed.rs +++ b/crates/radicle-cli/src/commands/unseed.rs @@ -5,7 +5,6 @@ use radicle::{prelude::*, Node}; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/unseed/args.rs b/crates/radicle-cli/src/commands/unseed/args.rs index 47544107..2c579266 100644 --- a/crates/radicle-cli/src/commands/unseed/args.rs +++ b/crates/radicle-cli/src/commands/unseed/args.rs @@ -1,7 +1,7 @@ use clap::Parser; use radicle::prelude::RepoId; -pub(crate) const ABOUT: &str = "Remove repository seeding policies"; +const ABOUT: &str = "Remove repository seeding policies"; const LONG_ABOUT: &str = r#" The `unseed` command removes the seeding policy, if found, diff --git a/crates/radicle-cli/src/commands/watch.rs b/crates/radicle-cli/src/commands/watch.rs index 5c454ecf..bd72a33f 100644 --- a/crates/radicle-cli/src/commands/watch.rs +++ b/crates/radicle-cli/src/commands/watch.rs @@ -12,7 +12,6 @@ use radicle::storage::{ReadRepository, ReadStorage}; use crate::terminal as term; pub use args::Args; -pub(crate) use args::ABOUT; pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { let profile = ctx.profile()?; diff --git a/crates/radicle-cli/src/commands/watch/args.rs b/crates/radicle-cli/src/commands/watch/args.rs index ee989c8b..a67f011b 100644 --- a/crates/radicle-cli/src/commands/watch/args.rs +++ b/crates/radicle-cli/src/commands/watch/args.rs @@ -7,7 +7,7 @@ use radicle::git; use radicle::git::fmt::RefString; use radicle::prelude::{NodeId, RepoId}; -pub(crate) const ABOUT: &str = "Wait for some state to be updated"; +const ABOUT: &str = "Wait for some state to be updated"; const LONG_ABOUT: &str = r#" Watches a Git reference, and optionally exits when it reaches a target value. diff --git a/crates/radicle-cli/src/terminal.rs b/crates/radicle-cli/src/terminal.rs index dbad96b1..07a5a11f 100644 --- a/crates/radicle-cli/src/terminal.rs +++ b/crates/radicle-cli/src/terminal.rs @@ -1,7 +1,10 @@ pub mod args; +use std::process; + pub use args::{Args, Error, Help}; pub mod format; pub mod io; +use clap::Parser; pub use io::signer; pub mod cob; pub mod comment; @@ -11,17 +14,10 @@ pub mod json; pub mod patch; pub mod upload_pack; -use std::ffi::OsString; -use std::process; - -use clap::Parser; - pub use radicle_term::*; use radicle::profile::{Home, Profile}; -use crate::terminal; - /// Context passed to all commands. pub trait Context { /// Return the currently active profile, or an error if no profile is active. @@ -72,74 +68,6 @@ where } } -pub fn run_command(help: Help, cmd: C) -> ! -where - A: Args, - C: Command, -{ - let args = std::env::args_os().skip(1).collect(); - - run_command_args(help, cmd, args) -} - -pub fn run_command_args(help: Help, cmd: C, args: Vec) -> ! -where - A: Args, - C: Command, -{ - use io as term; - - let options = match A::from_args(args) { - Ok((opts, unparsed)) => { - if let Err(err) = args::finish(unparsed) { - term::error(err); - process::exit(1); - } - opts - } - Err(err) => { - let hint = match err.downcast_ref::() { - Some(Error::Help) => { - help.print(); - process::exit(0); - } - // Print the manual, or the regular help if there's an error. - Some(Error::HelpManual { name }) => { - let Ok(status) = term::manual(name) else { - help.print(); - process::exit(0); - }; - if !status.success() { - help.print(); - process::exit(0); - } - process::exit(status.code().unwrap_or(0)); - } - Some(Error::Usage) => { - term::usage(help.name, help.usage); - process::exit(1); - } - Some(Error::WithHint { hint, .. }) => Some(hint), - None => None, - }; - io::error(format!("rad {}: {err}", help.name)); - - if let Some(hint) = hint { - io::hint(hint); - } - process::exit(1); - } - }; - - match cmd.run(options, DefaultContext) { - Ok(()) => process::exit(0), - Err(err) => { - terminal::fail(help.name, &err); - process::exit(1); - } - } -} - /// Gets the default profile. Fails if there is no profile. pub struct DefaultContext;