Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
bin: Handle `--no-forward` in help command
Erik Kundt committed 1 year ago
commit a4f804fa18b93b8648e833c888bc53472ce90135
parent bbee421
1 file changed +15 -2
modified bin/commands/help.rs
@@ -22,10 +22,23 @@ 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);
+
        let mut forward = true;

-
        if let Some(arg) = parser.next()? {
-
            return Err(anyhow::anyhow!(arg.unexpected()));
+
        while let Some(arg) = parser.next()? {
+
            match arg {
+
                Long("no-forward") => {
+
                    forward = false;
+
                }
+
                _ => {
+
                    if !forward {
+
                        return Err(Error::HelpManual { name: "rad-tui" }.into());
+
                    }
+
                    return Err(anyhow::anyhow!(arg.unexpected()));
+
                }
+
            }
        }
        Err(Error::HelpManual { name: "rad-tui" }.into())
    }