Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
bin: `rad` can be called with a command
Erik Kundt committed 1 year ago
commit 9f12c981809ab0fcaadc70d731f0d8ec68e5c9d1
parent 2d4a06d
4 files changed +12 -8
modified bin/commands/inbox.rs
@@ -222,11 +222,11 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul
                }

                let args = args.into_iter().map(OsString::from).collect::<Vec<_>>();
-
                let _ = crate::terminal::run_rad("inbox", &args);
+
                let _ = crate::terminal::run_rad(Some("inbox"), &args);
            }
        }
        Operation::Other { args } => {
-
            let _ = crate::terminal::run_rad("inbox", &args);
+
            let _ = crate::terminal::run_rad(Some("inbox"), &args);
        }
    }

modified bin/commands/issue.rs
@@ -225,11 +225,11 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul
                }

                let args = args.into_iter().map(OsString::from).collect::<Vec<_>>();
-
                let _ = crate::terminal::run_rad("issue", &args);
+
                let _ = crate::terminal::run_rad(Some("issue"), &args);
            }
        }
        Operation::Other { args } => {
-
            let _ = crate::terminal::run_rad("issue", &args);
+
            let _ = crate::terminal::run_rad(Some("issue"), &args);
        }
    }

modified bin/commands/patch.rs
@@ -278,7 +278,7 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul
                }

                let args = args.into_iter().map(OsString::from).collect::<Vec<_>>();
-
                let _ = crate::terminal::run_rad("patch", &args);
+
                let _ = crate::terminal::run_rad(Some("patch"), &args);
            }
        }
        Operation::Review { ref opts } => {
@@ -298,7 +298,7 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul
            interface::review(opts.clone(), profile, rid, patch_id).await?;
        }
        Operation::Other { args } => {
-
            let _ = crate::terminal::run_rad("patch", &args);
+
            let _ = crate::terminal::run_rad(Some("patch"), &args);
        }
    }

modified bin/terminal.rs
@@ -30,8 +30,12 @@ fn _run_rad(args: &[OsString]) -> Result<(), Option<anyhow::Error>> {
    Ok(())
}

-
pub fn run_rad(command: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>> {
-
    let args = [vec![command.into()], args.to_vec()].concat();
+
pub fn run_rad(command: Option<&str>, args: &[OsString]) -> Result<(), Option<anyhow::Error>> {
+
    let args = if let Some(command) = command {
+
        [vec![command.into()], args.to_vec()].concat()
+
    } else {
+
        args.to_vec()
+
    };

    _run_rad(&args)
}