Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Open manual on `rad help`
cloudhead committed 2 years ago
commit 725660ed515fbd8d6d00b93ebe58879e8f4bd9ef
parent 6d791ee143c86ba1a3dca870089732f47a793740
5 files changed +7 -16
modified radicle-cli/src/commands/help.rs
@@ -44,19 +44,12 @@ pub struct Options {}

impl Args for Options {
    fn from_args(args: Vec<OsString>) -> anyhow::Result<(Self, Vec<OsString>)> {
-
        use lexopt::prelude::*;
-

        let mut parser = lexopt::Parser::from_args(args);

        if let Some(arg) = parser.next()? {
-
            match arg {
-
                Long("help") | Short('h') => {
-
                    return Err(Error::Help.into());
-
                }
-
                _ => return Err(anyhow::anyhow!(arg.unexpected())),
-
            }
+
            return Err(anyhow::anyhow!(arg.unexpected()));
        }
-
        Ok((Options {}, vec![]))
+
        Err(Error::HelpManual { name: "rad" }.into())
    }
}

modified radicle-cli/src/commands/patch.rs
@@ -302,7 +302,7 @@ impl Args for Options {
                    quiet = true;
                }
                Long("help") => {
-
                    return Err(Error::HelpManual.into());
+
                    return Err(Error::HelpManual { name: "rad-patch" }.into());
                }
                Short('h') => {
                    return Err(Error::Help.into());
modified radicle-cli/src/terminal.rs
@@ -84,8 +84,8 @@ where
                    term::help(help.name, help.version, help.description, help.usage);
                    process::exit(0);
                }
-
                Some(Error::HelpManual) => {
-
                    let Ok(status) = term::manual(help.name) else {
+
                Some(Error::HelpManual { name }) => {
+
                    let Ok(status) = term::manual(name) else {
                        io::error(format!("rad {}: failed to load manual page", help.name));
                        process::exit(1);
                    };
modified radicle-cli/src/terminal/args.rs
@@ -19,7 +19,7 @@ pub enum Error {
    Help,
    /// If this error is returned from argument parsing, the manual page is displayed.
    #[error("help manual invoked")]
-
    HelpManual,
+
    HelpManual { name: &'static str },
    /// If this error is returned from argument parsing, usage is displayed.
    #[error("usage invoked")]
    Usage,
modified radicle-term/src/io.rs
@@ -139,9 +139,7 @@ pub fn help(name: &str, version: &str, description: &str, usage: &str) {
}

pub fn manual(name: &str) -> io::Result<process::ExitStatus> {
-
    let mut child = process::Command::new("man")
-
        .arg(format!("rad-{name}"))
-
        .spawn()?;
+
    let mut child = process::Command::new("man").arg(name).spawn()?;

    child.wait()
}