mod client;
mod commands;
mod output;
mod sites;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(
name = "oxipage",
version,
about = "Oxipage personal-site CLI — every command is an authenticated HTTP call",
long_about = "doc/04 §4.1: CLI는 API의 레퍼런스 클라이언트. 모든 쓰기/읽기는 인증된 HTTP 호출이다.\n유일한 예외는 serve 자체가 서버 프로세스를 기동하는 것뿐이다."
)]
pub struct Cli {
#[arg(long, global = true, env = "OXIPAGE_ENDPOINT")]
pub endpoint: Option<String>,
#[arg(long, global = true, env = "OXIPAGE_SITE")]
pub site: Option<String>,
#[arg(long, global = true, env = "OXIPAGE_TOKEN")]
pub token: Option<String>,
#[arg(long, global = true)]
pub json: bool,
#[arg(long, global = true, env = "OXIPAGE_CONFIG")]
pub config: Option<PathBuf>,
#[arg(long, global = true, env = "OXIPAGE_TLS_INSECURE")]
pub insecure: bool,
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand, Debug, Clone)]
pub enum Command {
Init {
#[arg(long)]
wizard: bool,
},
Status,
Console {
#[arg(long)]
port: Option<u16>,
#[arg(long)]
preview: bool,
},
Open {
#[arg(long)]
port: Option<u16>,
},
#[command(subcommand)]
Blog(commands::BlogCommand),
#[command(subcommand)]
Project(commands::ProjectCommand),
#[command(subcommand)]
Link(commands::LinkCommand),
#[command(subcommand)]
Lobby(commands::LobbyCommand),
#[command(subcommand)]
Extension(commands::ExtensionCommand),
#[command(subcommand)]
Backup(commands::BackupCommand),
Build(commands::BuildCommand),
Cache(commands::CacheArgs),
Deploy(commands::DeployArgs),
Query(commands::QueryCommand),
Schema(commands::SchemaCommand),
#[command(subcommand)]
Site(commands::SiteCommand),
#[clap(external_subcommand)]
Dynamic(Vec<String>),
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
commands::dispatch(cli).await
}