Abbaye

at e1dfdc3

use std::path::PathBuf;

use clap::Parser;
use clap::Subcommand;

pub const RESET: &str = "\x1b[0m";

pub const RED: &str = "\x1b[31m";
pub const GREEN: &str = "\x1b[32m";
pub const YELLOW: &str = "\x1b[33m";
pub const BLUE: &str = "\x1b[34m";
pub const MAGENTA: &str = "\x1b[35m";
pub const CYAN: &str = "\x1b[36m";

/// Array to cycle through ANSI color escape codes for builder spinner prefixes.
pub const COLOURS: &[&str] = &[CYAN, GREEN, YELLOW, MAGENTA, BLUE, RED];

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct CliArgs {
    /// Verbosity level (0 = normal, 1 = verbose, 2 = debug)
    #[arg(short, long, default_value_t = 0, action=clap::ArgAction::Count)]
    pub verbose: u8,
    #[command(subcommand)]
    pub command: CliCommand,
}

#[derive(Subcommand, Debug, Clone)]
pub enum CliCommand {
    /// Initialize a new abbaye.toml file
    Init {
        /// path to directory to initialize in
        path: Option<PathBuf>,
    },
    /// Build the site
    Build {
        /// Only regenerate the git repository web UI; skip the version page builds.
        /// Requires `[git_ui]` to be configured in `abbaye.toml`.
        #[arg(long)]
        repository_only: bool,
    },
    /// Build the site for every git tag, starting from the lowest semver version.
    /// Checks out each tag in order, builds, then restores the original HEAD.
    BuildAll,
    /// Dumps the default theme to `.abbaye/theme` so you can inspect and modify it. It will be used afterwards when building the site.
    DumpTheme,
    /// Print a JSON Schema for `abbaye.toml` to stdout.
    ///
    /// Redirect the output to a file (e.g. `abbaye dump-schema > abbaye.schema.json`) and
    /// point your editor or TOML language server at it to get field descriptions and
    /// auto-completion while editing `abbaye.toml`.
    DumpSchema,
    /// Check for a newer version of abbaye and update the binary if one is available.
    SelfUpdate {
        /// Only check whether an update is available; do not download or replace the binary.
        #[arg(short, long)]
        check: bool,
    },
    /// Print a usage spec (https://usage.jdx.dev) to stdout.
    ///
    /// Pipe the output to the `usage` CLI to generate shell completions, man pages, or docs:
    ///   `abbaye usage-spec | usage generate completion bash`
    ///   `abbaye usage-spec | usage generate manpage --out-file abbaye.1`
    #[command(hide = true)]
    UsageSpec,
}