Skip to main content

zoi_cli/cmd/package/
mod.rs

1use anyhow::Result;
2use clap::{Parser, Subcommand};
3pub mod build;
4pub mod bundle;
5pub mod doctor;
6pub mod init_lsp;
7pub mod inspect;
8pub mod install;
9pub mod test;
10
11#[derive(Parser, Debug)]
12pub struct PackageCommand {
13    #[command(subcommand)]
14    command: Commands,
15}
16
17#[derive(Subcommand, Debug)]
18enum Commands {
19    /// Build a package from a pkg.lua file
20    Build(build::BuildCommand),
21    /// Bundle a package and its local assets into a .zsa archive
22    Bundle(bundle::BundleCommand),
23    /// Test a package from a pkg.lua file
24    Test(build::BuildCommand),
25    /// Install a package from a local archive
26    Install(install::InstallCommand),
27    /// Lint and validate a package definition for maintainers
28    Doctor(doctor::DoctorCommand),
29    /// Initialize LSP support for .pkg.lua files
30    InitLsp(init_lsp::InitLspCommand),
31    /// Inspect a package definition and output metadata
32    Inspect(inspect::InspectCommand),
33}
34
35pub fn run(args: PackageCommand) -> Result<()> {
36    match args.command {
37        Commands::Build(cmd) => build::run(cmd),
38        Commands::Bundle(cmd) => bundle::run(cmd),
39        Commands::Test(cmd) => test::run(cmd),
40        Commands::Install(cmd) => install::run(cmd),
41        Commands::Doctor(cmd) => doctor::run(cmd),
42        Commands::InitLsp(cmd) => init_lsp::run(cmd),
43        Commands::Inspect(cmd) => inspect::run(cmd),
44    }
45}