// Copyright (C) 2022-2023 Enrico Guiraud
//
// This file is part of Kobold, a static site generator with a friendly CLI.
//
// Kobold is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Kobold is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kobold. If not, see <http://www.gnu.org/licenses/>.

use clap::{Parser, Subcommand};

/// Kobold's CLI argument parser
#[derive(Parser)]
#[command(name = "kobold")]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
// must be pub in order for build.rs to build the man page
pub struct Cli {
    #[clap(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    #[allow(rustdoc::invalid_html_tags)]
    /// Create a new Kobold project in the specified directory.
    ///
    /// Directory <DIR> will be populated with the appropriate directory structure
    /// and a default theme and home page.
    Init { dir: std::path::PathBuf },
    #[allow(rustdoc::invalid_html_tags)]
    /// Generate website from the Kobold project at the specified directory.
    ///
    /// The generated website will be available at <DIR>/site.
    Build {
        /// Path to the website sources.
        /// This is the parent directory of directories `content`, `layouts`, etc.
        /// The website is created at `DIR/site`.
        dir: std::path::PathBuf,
        /// When this option is present, the '/tags' web page is not generated.
        #[clap(long)]
        no_tags: bool,
        /// When this option is present, kobold generates a search bar for the website.
        #[clap(long)]
        with_search_bar: bool,
    },
}

#[test]
fn verify_cli() {
    use clap::CommandFactory;
    Cli::command().debug_assert()
}
