-
Notifications
You must be signed in to change notification settings - Fork 477
Expand file tree
/
Copy pathgenerate.rs
More file actions
26 lines (23 loc) · 852 Bytes
/
generate.rs
File metadata and controls
26 lines (23 loc) · 852 Bytes
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
//! Functionality related to running `cargo-generate`.
use crate::child;
use crate::emoji;
use crate::install::{self, Tool};
use anyhow::{Context, Result};
use std::process::Command;
/// Run `cargo generate` in the current directory to create a new
/// project from a template
pub fn generate(template: &str, name: &str, install_status: &install::Status) -> Result<()> {
let bin_path = install::get_tool_path(install_status, Tool::CargoGenerate)?
.binary(&Tool::CargoGenerate.to_string())?;
let mut cmd = Command::new(&bin_path);
cmd.arg("generate");
cmd.arg("--git").arg(template);
cmd.arg("--name").arg(name);
println!(
"{} Generating a new rustwasm project with name '{}'...",
emoji::SHEEP,
name
);
child::run(cmd, "cargo-generate").context("Running cargo-generate")?;
Ok(())
}