29 lines
705 B
Rust
29 lines
705 B
Rust
use std::io::Result;
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::{Command, Output};
|
|
|
|
pub struct ComposeProject {
|
|
compose_file: PathBuf,
|
|
}
|
|
|
|
impl ComposeProject {
|
|
pub fn new(compose_file: &PathBuf) -> ComposeProject {
|
|
ComposeProject {
|
|
compose_file: compose_file.to_owned(),
|
|
}
|
|
}
|
|
|
|
fn working_directory(&self) -> &Path {
|
|
self.compose_file
|
|
.parent()
|
|
.expect("Failed to get parent of compose file")
|
|
}
|
|
|
|
fn execute_in_dir(&self, command: &str, arguments: &[&str]) -> Result<Output> {
|
|
Command::new(command)
|
|
.current_dir(self.working_directory())
|
|
.args(arguments)
|
|
.output()
|
|
}
|
|
}
|