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

use super::ADBCommand;

pub struct ADBPush {
    path: Option<String>,
    local: String,
    remote: String,
}
impl ADBPush {
    pub fn new(local: &str, remote: &str) -> Self {
        ADBPush {
            path: None,
            local: local.to_owned(),
            remote: remote.to_owned(),
        }
    }
}

impl ADBCommand for ADBPush {
    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("push")
                    .arg(&self.local)
                    .arg(format!("{}{}", path, self.remote));
                Ok(shell)
            }
            None => Err("No path specified".to_string()),
        }
    }
}