1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::process::Command;

use crate::{ADBPathCommand, ADBResult};

pub struct ADBList {
    path: Option<String>,
    shell: Command,
}

impl Default for ADBList {
    fn default() -> Self {
        let mut cmd = Command::new("adb");
        cmd.arg("shell").arg("ls");

        ADBList {
            path: None,
            shell: cmd,
        }
    }
}

impl ADBPathCommand for ADBList {
    fn path(&mut self, path: Option<String>) {
        self.path = path
    }

    fn build(&mut self) -> Result<&mut Command, String> {
        match &self.path {
            Some(path) => {
                self.shell.arg(path);
                Ok(&mut self.shell)
            }
            None => Ok(&mut self.shell),
        }
    }

    fn process_output(&self, output: ADBResult) -> ADBResult {
        output
    }
}