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
40
use crate::error::Result;
use clap::Parser;
use crossbundle_tools::{
commands::{check_cargo_generate, create_project},
utils::Config,
};
const TEMPLATES_REPO: &str = "https://github.com/dodorare/crossbundle-templates.git";
#[derive(Parser, Clone, Debug)]
pub struct NewCommand {
pub name: String,
#[clap(long, short)]
pub template: Option<String>,
#[clap(long, short)]
pub force: bool,
}
impl NewCommand {
pub fn handle_command(&self, config: &Config) -> Result<()> {
if !check_cargo_generate() {
config
.shell()
.warn("To use `crossbundle new ...` command you need to install `cargo-generate`\n run `cargo install cargo-generate`")?;
return Ok(());
};
create_project(
config.current_dir(),
&self.name,
TEMPLATES_REPO,
&self.template,
)?;
Ok(())
}
}