Skip to main content

xianyun_executor/exec/
repository.rs

1//! Decorators applied to commands executed within a repository directory.
2//!
3//! Ported from `internal/executor/repository.go`.
4
5use crate::exec::ExecError;
6
7/// A minimal stand-in for `*cmd.Cmd` (the `go-cmd` package's command
8/// builder), narrowed to the fields [`mise_decorator`](super::mise_decorator)
9/// actually reads or mutates (`Name`, `Args`, `Env`, `Dir`).
10#[derive(Debug, Clone, Default)]
11pub struct Command {
12    pub name: String,
13    pub args: Vec<String>,
14    pub env: Option<Vec<String>>,
15    pub dir: Option<String>,
16}
17
18/// Ported from `repositoryExecutorDecorator`.
19pub trait RepositoryExecutorDecorator {
20    fn wrap(&self, original: Command) -> Result<Command, ExecError>;
21}
22
23/// Ported from `getRepositoryDecorators`.
24pub fn get_repository_decorators() -> Vec<Box<dyn RepositoryExecutorDecorator>> {
25    vec![Box::new(super::mise_decorator::MiseDecorator)]
26}
27
28#[cfg(test)]
29mod tests {
30    use super::*;
31
32    #[test]
33    fn get_repository_decorators_returns_decorators() {
34        let decorators = get_repository_decorators();
35        assert!(
36            !decorators.is_empty(),
37            "should return at least one decorator"
38        );
39    }
40}