crossbundle_tools/commands/common/
create_project.rs1use crate::error::*;
2use std::path::Path;
3use std::process::Command;
4
5pub fn create_project(
8 current_dir: &Path,
9 name: &str,
10 git: &str,
11 branch: &Option<String>,
12) -> Result<()> {
13 let mut cargo_generate = Command::new("cargo");
14 cargo_generate
15 .current_dir(current_dir)
16 .arg("generate")
17 .arg("--git")
18 .arg(git)
19 .arg("--name")
20 .arg(name);
21 if let Some(branch) = branch {
22 cargo_generate.arg("--branch").arg(branch);
23 };
24 cargo_generate.output_err(true)?;
25 Ok(())
26}
27
28pub fn check_cargo_generate() -> bool {
30 Command::new("cargo")
31 .arg("generate")
32 .arg("-V")
33 .output()
34 .map(|s| s.status.success())
35 .unwrap_or(false)
36}