esmeril 0.1.0

Scaffold, check and inspect Roblox Luau projects
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(
    name = "esmeril",
    version,
    about = "Scaffold, check and inspect Roblox Luau projects"
)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,

    /// Emit machine-readable JSON to stdout instead of the table
    #[arg(global = true, long, id = "json_out")]
    pub json: bool,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Scaffold a modern Roblox project: Rojo, Selene, StyLua, Aftman, Wally and CI
    Init(InitArgs),
    /// Inspect a project: tooling configs, structure and an A-F grade
    Check(CheckArgs),
    /// Audit wally.toml dependencies against the package registry
    Deps(DepsArgs),
    /// Bump wally.toml requirements to the latest published versions
    Update(UpdateArgs),
    /// Run the formatter and linter on the source tree
    Fmt(FmtArgs),
    /// Check the project and build it with Rojo
    Build(BuildArgs),
    /// Check the local toolchain: rojo, selene, stylua, wally and aftman
    Doctor,
    /// Generate shell completion scripts
    Completions {
        /// Shell to generate for: bash, zsh, fish, powershell, elvish
        #[arg(value_enum)]
        shell: clap_complete::Shell,
    },
}

#[derive(clap::Args)]
pub struct InitArgs {
    /// Directory to create; defaults to the current directory name
    pub name: Option<String>,

    /// Use Luau language mode Strict instead of NonStrict
    #[arg(long)]
    pub strict: bool,

    /// Scaffold a library package (for publishing to Wally) instead of a game
    #[arg(long)]
    pub lib: bool,

    /// Overwrite files when the target directory is not empty
    #[arg(long)]
    pub force: bool,
}

#[derive(clap::Args)]
pub struct CheckArgs {
    /// Project directory to inspect; defaults to the current directory
    #[arg(default_value = ".")]
    pub path: String,

    /// Create the standard files that are missing instead of only reporting
    #[arg(long)]
    pub fix: bool,

    /// Print the report as a markdown table instead of the text report
    #[arg(long)]
    pub markdown: bool,
}

#[derive(clap::Args)]
pub struct DepsArgs {
    /// Project directory to inspect; defaults to the current directory
    #[arg(default_value = ".")]
    pub path: String,

    /// Use only the local index cache; fail when a package is not cached
    #[arg(long)]
    pub offline: bool,
}

#[derive(clap::Args)]
pub struct FmtArgs {
    /// Project directory to inspect; defaults to the current directory
    #[arg(default_value = ".")]
    pub path: String,

    /// Only report problems, do not format
    #[arg(long)]
    pub check: bool,
}

#[derive(clap::Args)]
pub struct BuildArgs {
    /// Project directory to inspect; defaults to the current directory
    #[arg(default_value = ".")]
    pub path: String,

    /// Output file name (defaults to game.rbxl or lib.rbxm)
    #[arg(short, long)]
    pub output: Option<String>,
}

#[derive(clap::Args)]
pub struct UpdateArgs {
    /// Project directory to inspect; defaults to the current directory
    #[arg(default_value = ".")]
    pub path: String,

    /// Write the new requirements to wally.toml (dry-run by default)
    #[arg(long)]
    pub write: bool,

    /// Use only the local index cache; fail when a package is not cached
    #[arg(long)]
    pub offline: bool,
}