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
use platform_lp::Platform;
use version_lp::Version;

use failure::Error;

use std::path::{Path,PathBuf};
use binary;

pub fn run<P : AsRef<Path>>(plat : &Platform, ver : &Version, package_path : Option<P>) -> Result<(),Error> {
    //! runs love based on a ***platform*** and a ***version***
    //! 
    //! will attempt to install a version of doesn't exist locally. if that initial install
    //! fails then run will fail.

    let exe_path = PathBuf::from(binary::build_path(plat,ver)?);
    if !exe_path.exists() {
        info!("love {} {} not found, attempting to install.",plat,ver);
        binary::install(plat,ver)?;
    }

    let package = if let Some(path) = package_path {
        let path = PathBuf::from(path.as_ref());
        info!("Found love project at '{}'",path.display().to_string());
        Some(path)
    } else {
        None
    };

    binary::run(exe_path,package)
}