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
use std::process::Command;

use super::ADBCommand;

pub struct ADBPull {
    path: Option<String>,
    remote: String,
    local: String,
}

impl ADBPull {
    pub fn new(remote: &str, local: &str) -> Self {
        ADBPull {
            path: None,
            remote: remote.to_owned(),
            local: local.to_owned(),
        }
    }
}

impl ADBCommand for ADBPull {
    fn path(&mut self, path: String) {
        self.path = Some(path);
    }

    fn build(&self) -> Result<Command, String> {
        match &self.path {
            Some(path) => {
                let mut shell = Command::new("adb");
                shell
                    .arg("pull")
                    .arg(format!("{}{}", path, self.remote))
                    .arg(&self.local);
                Ok(shell)
            }
            None => Err("No path specified".to_string()),
        }
    }
}