1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::process::Command;

use anyhow::Result;
use clap::Args;

use crate::app::CommandExt as _;

/// Execute a command within the repository
#[derive(Args, Debug)]
#[command()]
pub struct Cli {
    #[arg(required = true, trailing_var_arg = true, allow_hyphen_values = true)]
    args: Vec<String>,
}

impl Cli {
    pub fn exec(self) -> Result<()> {
        let status = Command::new(&self.args[0])
            .in_repo()
            .args(&self.args[1..])
            .run()?;
        std::process::exit(status.code().unwrap_or(1));
    }
}