1mod error;
2use command::{DownCommand, PsCommand, ScaleCommand, StartCommand, StatsCommand, UpCommand};
3pub use error::{ComposeBuilderError, ComposeError};
4mod builder;
5pub use builder::ComposeBuilder;
6pub mod command;
7mod container;
8mod parser;
9pub use command::ComposeCommand;
10
11pub struct Compose {
12 path: String,
13}
14
15impl Compose {
16 pub fn builder() -> ComposeBuilder {
17 ComposeBuilder::new()
18 }
19
20 pub fn from_file(path: &str) -> Result<Self, ComposeBuilderError> {
21 let builder = Self::builder().path(path);
22 builder.build()
23 }
24
25 fn init_command(&self) -> std::process::Command {
26 let mut cmd = std::process::Command::new("docker");
27 cmd.arg("compose").arg("-f").arg(&self.path);
28 cmd
29 }
30
31 pub fn up(&self) -> UpCommand {
32 UpCommand::new(self.init_command())
33 }
34
35 pub fn down(&self) -> DownCommand {
36 DownCommand::new(self.init_command())
37 }
38
39 pub fn ps(&self) -> PsCommand {
40 PsCommand::new(self.init_command())
41 }
42
43 pub fn scale(&self) -> ScaleCommand {
44 ScaleCommand::new(self.init_command())
45 }
46
47 pub fn stats(&self) -> StatsCommand {
48 StatsCommand::new(self.init_command())
49 }
50
51 pub fn start(&self) -> StartCommand {
52 StartCommand::new(self.init_command())
53 }
54}
55
56pub mod prelude {
57 pub use crate::Compose;
58 pub use crate::ComposeBuilder;
59 pub use crate::ComposeBuilderError;
60 pub use crate::ComposeCommand;
61 pub use crate::ComposeError;
62}