Skip to main content

abbaye/
cli.rs

1use std::path::PathBuf;
2
3use clap::Parser;
4use clap::Subcommand;
5
6#[derive(Parser, Debug)]
7#[command(author, version, about, long_about = None)]
8pub struct CliArgs {
9    /// Verbosity level (0 = normal, 1 = verbose, 2 = debug)
10    #[arg(short, long, default_value_t = 0, action=clap::ArgAction::Count)]
11    pub verbose: u8,
12    #[command(subcommand)]
13    pub command: CliCommand,
14}
15
16#[derive(Subcommand, Debug, Clone)]
17pub enum CliCommand {
18    /// Initialize a new abbaye.toml file
19    Init {
20        /// path to directory to initialize in
21        path: Option<PathBuf>,
22    },
23    /// Build the site
24    Build,
25    /// Build the site for every git tag, starting from the lowest semver version.
26    /// Checks out each tag in order, builds, then restores the original HEAD.
27    BuildAll,
28    /// Dumps the default theme to `.abbaye/theme` so you can inspect and modify it. It will be used afterwards when building the site.
29    DumpTheme,
30    /// Print a JSON Schema for `abbaye.toml` to stdout.
31    ///
32    /// Redirect the output to a file (e.g. `abbaye dump-schema > abbaye.schema.json`) and
33    /// point your editor or TOML language server at it to get field descriptions and
34    /// auto-completion while editing `abbaye.toml`.
35    DumpSchema,
36    /// Check for a newer version of abbaye and update the binary if one is available.
37    SelfUpdate {
38        /// Only check whether an update is available; do not download or replace the binary.
39        #[arg(short, long)]
40        check: bool,
41    },
42    /// Print a usage spec (https://usage.jdx.dev) to stdout.
43    ///
44    /// Pipe the output to the `usage` CLI to generate shell completions, man pages, or docs:
45    ///   `abbaye usage-spec | usage generate completion bash`
46    ///   `abbaye usage-spec | usage generate manpage --out-file abbaye.1`
47    #[command(hide = true)]
48    UsageSpec,
49}