diff --git a/crates/radicle-cli/examples/rad-help.md b/crates/radicle-cli/examples/rad-help.md index 6223977a..90f95704 100644 --- a/crates/radicle-cli/examples/rad-help.md +++ b/crates/radicle-cli/examples/rad-help.md @@ -11,6 +11,7 @@ Common `rad` commands used in various situations: checkout Checkout a repository into the local directory clone Clone a Radicle repository config Manage your local Radicle configuration + debug Write out information to help debug your Radicle node remotely fork Create a fork of a repository help CLI help id Manage repository identities diff --git a/crates/radicle-cli/src/commands/debug.rs b/crates/radicle-cli/src/commands/debug.rs index fb43989c..0d47bb0d 100644 --- a/crates/radicle-cli/src/commands/debug.rs +++ b/crates/radicle-cli/src/commands/debug.rs @@ -1,7 +1,7 @@ -#![allow(clippy::or_fun_call)] +mod args; + use std::collections::BTreeMap; use std::env; -use std::ffi::OsString; use std::path::PathBuf; use std::process::Command; @@ -11,40 +11,16 @@ use serde::Serialize; use radicle::Profile; use crate::terminal as term; -use crate::terminal::args::{Args, Help}; + +pub use args::Args; +pub(crate) use args::ABOUT; pub const NAME: &str = "rad"; pub const VERSION: &str = env!("RADICLE_VERSION"); pub const DESCRIPTION: &str = "Radicle command line interface"; pub const GIT_HEAD: &str = env!("GIT_HEAD"); -pub const HELP: Help = Help { - name: "debug", - description: "Write out information to help debug your Radicle node remotely", - version: env!("RADICLE_VERSION"), - usage: r#" -Usage - - rad debug - - Run this if you are reporting a problem in Radicle. The output is - helpful for Radicle developers to debug your problem remotely. The - output is meant to not include any sensitive information, but - please check it, and then forward to the Radicle developers. - -"#, -}; - -#[derive(Debug)] -pub struct Options {} - -impl Args for Options { - fn from_args(_args: Vec) -> anyhow::Result<(Self, Vec)> { - Ok((Options {}, vec![])) - } -} - -pub fn run(_options: Options, ctx: impl term::Context) -> anyhow::Result<()> { +pub fn run(_args: Args, ctx: impl term::Context) -> anyhow::Result<()> { match ctx.profile() { Ok(profile) => debug(Some(&profile)), Err(e) => { diff --git a/crates/radicle-cli/src/commands/debug/args.rs b/crates/radicle-cli/src/commands/debug/args.rs new file mode 100644 index 00000000..b2fabc97 --- /dev/null +++ b/crates/radicle-cli/src/commands/debug/args.rs @@ -0,0 +1,13 @@ +use clap::Parser; + +pub 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 +helpful for Radicle developers to debug your problem remotely. The +output is meant to not include any sensitive information, but +please check it, and then forward to the Radicle developers."#; + +#[derive(Parser, Debug)] +#[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)] +pub struct Args {} diff --git a/crates/radicle-cli/src/commands/help.rs b/crates/radicle-cli/src/commands/help.rs index 116f2be4..fb479b9a 100644 --- a/crates/radicle-cli/src/commands/help.rs +++ b/crates/radicle-cli/src/commands/help.rs @@ -45,6 +45,10 @@ const COMMANDS: &[CommandItem] = &[ CommandItem::Lexopt(crate::commands::checkout::HELP), CommandItem::Lexopt(crate::commands::clone::HELP), CommandItem::Lexopt(crate::commands::config::HELP), + CommandItem::Clap { + name: "debug", + about: crate::commands::debug::ABOUT, + }, CommandItem::Lexopt(crate::commands::fork::HELP), CommandItem::Lexopt(crate::commands::help::HELP), CommandItem::Lexopt(crate::commands::id::HELP), diff --git a/crates/radicle-cli/src/main.rs b/crates/radicle-cli/src/main.rs index b443b574..713ed03a 100644 --- a/crates/radicle-cli/src/main.rs +++ b/crates/radicle-cli/src/main.rs @@ -47,6 +47,7 @@ struct CliArgs { enum Commands { Block(block::Args), Clean(clean::Args), + Debug(debug::Args), Issue(issue::Args), Path(path::Args), Stats(stats::Args), @@ -203,7 +204,9 @@ pub(crate) fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option(diff::HELP, diff::run, args.to_vec()); } "debug" => { - term::run_command_args::(debug::HELP, debug::run, args.to_vec()); + if let Some(Commands::Debug(args)) = CliArgs::parse().command { + term::run_command_fn(debug::run, args); + } } "follow" => { term::run_command_args::(follow::HELP, follow::run, args.to_vec());