Skip to main content

zoi_cli/cmd/
create.rs

1//! Implementation of the `create` command for scaffolding new applications from
2//! templates.
3
4use anyhow::Result;
5use clap::Parser;
6
7use crate::pkg;
8
9/// Arguments for the `create` command.
10#[derive(Parser)]
11pub struct CreateCommand {
12    /// The source of the package (name, @repo/name, path to .pkg.lua, or URL)
13    pub source: String,
14    /// The application name and directory to create (defaults to package name)
15    pub app_name: Option<String>
16}
17
18/// Runs the `create` command.
19/// # Errors
20///
21/// Returns an error if the application cannot be created or dependencies cannot
22/// be resolved.
23pub fn run(
24    args: CreateCommand,
25    yes: bool,
26    plugin_manager: Option<&crate::pkg::plugin::PluginManager>
27) -> Result<()> {
28    pkg::create::run(&args.source, args.app_name, yes, plugin_manager)
29}