//! Command-line argument definitions for `org-gdocs`.
//!
//! The binary operates on an org file path and prints a JSON (or text) result
//! envelope, consumed by the companion Emacs package. All persistent state lives
//! in the org file itself; the binary is stateless across runs.

use std::path::PathBuf;

use clap::{Parser, Subcommand};
pub use tftio_cli_common::MetaCommand;

/// Top-level CLI for `org-gdocs`.
#[derive(Debug, Parser)]
#[command(name = "org-gdocs")]
#[command(about = "Sync org-mode documents to Google Docs and pull reviewer comments back")]
#[command(long_about = None)]
#[command(version)]
pub struct Cli {
    /// Subcommand to execute.
    #[command(subcommand)]
    pub command: Command,

    /// Emit machine-readable JSON instead of human-readable text.
    #[arg(short = 'j', long, global = true)]
    pub json: bool,
}

/// Domain subcommands plus the shared metadata commands.
#[derive(Debug, Subcommand)]
pub enum Command {
    /// Shared metadata commands (version, license, completions, doctor, agent).
    Meta {
        /// Shared metadata command to execute.
        #[command(subcommand)]
        command: MetaCommand,
    },
    /// Authenticate with Google via the OAuth loopback flow and cache a token.
    Auth,
    /// Publish a projection of the org file to its linked Google Doc.
    Push {
        /// Path to the org file to publish.
        file: PathBuf,
    },
    /// Pull reviewer comments from the linked Google Doc into the org file.
    Pull {
        /// Path to the org file to update.
        file: PathBuf,
    },
    /// Archive comments already marked DONE in the org file.
    Clean {
        /// Path to the org file to clean.
        file: PathBuf,
    },
    /// Print the browser URL of the org file's linked Google Doc.
    Open {
        /// Path to the org file whose linked doc URL to print.
        file: PathBuf,
    },
}
