Add helper methods for running commands inside the project directory
This commit is contained in:
parent
b83ec11e97
commit
120fea2a62
1 changed files with 16 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
use std::path::PathBuf;
|
||||
use std::io::Result;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
|
||||
pub struct ComposeProject {
|
||||
compose_file: PathBuf,
|
||||
|
@ -10,4 +12,17 @@ impl 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()
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue