1use crate::{container::Container, parser, ComposeCommand, ComposeError};
2
3use super::CatchOutput;
4
5pub struct PsCommand {
6 command: std::process::Command,
7}
8
9impl PsCommand {
10 pub fn new(command: std::process::Command) -> Self {
11 Self { command }
12 }
13}
14
15impl ComposeCommand<Vec<Container>> for PsCommand {
16 const COMMAND: &'static str = "ps";
17
18 fn exec(self) -> Result<Vec<Container>, ComposeError> {
19 let mut command = self.command;
20 command.arg(Self::COMMAND).arg("-a").arg("--no-trunc");
21
22 let output = command.output().catch_output()?;
23 let output = String::from_utf8_lossy(&output.stdout);
24
25 parser::parse_ps(&output)
26 }
27}