use std::path::PathBuf;
use std::time::Duration;
use clap::{Parser, Subcommand, ValueEnum};
#[derive(Debug, Parser)]
#[command(name = "sqlload", version, about)]
pub struct Cli {
#[arg(
long,
short,
global = true,
default_value = "sqlload.toml",
env = "SQLLOAD_CONFIG"
)]
pub config: PathBuf,
#[arg(long, global = true, value_enum, default_value_t = LogFormat::Text)]
pub log_format: LogFormat,
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
#[command(alias = "check")]
Debug {
#[arg(long)]
no_connection: bool,
},
Plan(LoaderArgs),
Tables {
#[arg(long)]
topics_file: Option<PathBuf>,
},
Apply(LoaderArgs),
Load(LoaderArgs),
Run {
#[arg(long, value_parser = humantime::parse_duration)]
max_duration: Option<Duration>,
#[arg(long, env = "SQLLOAD_SHARD")]
shard: Option<u32>,
},
Status,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, clap::Args)]
pub struct LoaderArgs {
pub select: Vec<String>,
#[arg(long)]
pub allow_type_change_rebuild: bool,
#[arg(long)]
pub reload: bool,
#[arg(long, conflicts_with = "start_cursor_int")]
pub start_cursor_ts: Option<String>,
#[arg(long, conflicts_with = "end_cursor_int")]
pub end_cursor_ts: Option<String>,
#[arg(long)]
pub start_cursor_int: Option<i64>,
#[arg(long)]
pub end_cursor_int: Option<i64>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum LogFormat {
Text,
Json,
}