use clap::{Args, Subcommand, ValueEnum};
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum Detail {
Summary,
Full,
}
impl Detail {
#[must_use]
pub const fn is_full(self) -> bool {
matches!(self, Self::Full)
}
#[must_use]
pub fn or_default(asked: Option<Self>, fallback: Self) -> bool {
asked.unwrap_or(fallback).is_full()
}
}
#[derive(Debug, Clone, Subcommand)]
pub enum SchemaCommand {
Map(MapArgs),
Databases,
Tables(TablesArgs),
Columns(DetailedTableArgs),
Keys(AdvisableTableArgs),
Indexes(AdvisableTableArgs),
Checks(DetailedTableArgs),
Views(ViewsArgs),
Routines(ScopeArgs),
Triggers(ScopeArgs),
Events(ScopeArgs),
Sequences(ScopeArgs),
Partitions(DetailedTableArgs),
Search(SearchArgs),
Stats(DetailedTableArgs),
Ddl(DdlArgs),
Count(TableArgs),
Size(SizeArgs),
Grants,
}
#[derive(Debug, Clone, Args)]
pub struct MapArgs {
#[arg(long)]
pub with_comments: bool,
}
#[derive(Debug, Clone, Args)]
pub struct ScopeArgs {
#[arg(long, value_name = "LEVEL")]
pub detail: Option<Detail>,
}
#[derive(Debug, Clone, Args)]
pub struct TablesArgs {
#[arg(long, value_name = "LEVEL")]
pub detail: Option<Detail>,
#[arg(long)]
pub all_databases: bool,
}
#[derive(Debug, Clone, Args)]
pub struct TableArgs {
#[arg(long)]
pub table: Option<String>,
}
#[derive(Debug, Clone, Args)]
pub struct DetailedTableArgs {
#[arg(long)]
pub table: Option<String>,
#[arg(long, value_name = "LEVEL")]
pub detail: Option<Detail>,
}
#[derive(Debug, Clone, Args)]
pub struct AdvisableTableArgs {
#[arg(long)]
pub table: Option<String>,
#[arg(long, value_name = "LEVEL")]
pub detail: Option<Detail>,
#[arg(long = "warn", alias = "advise")]
pub advise: bool,
}
#[derive(Debug, Clone, Args)]
pub struct ViewsArgs {
#[arg(long, value_name = "LEVEL")]
pub detail: Option<Detail>,
#[arg(long)]
pub materialized: bool,
}
#[derive(Debug, Clone, Args)]
pub struct SearchArgs {
pub pattern: Option<String>,
#[arg(long, value_name = "PATTERN")]
pub like: Option<String>,
#[arg(long = "type", alias = "kind", value_delimiter = ',')]
pub kind: Vec<String>,
#[arg(long, value_name = "LEVEL")]
pub detail: Option<Detail>,
}
#[derive(Debug, Clone, Args)]
pub struct DdlArgs {
pub object: Option<String>,
#[arg(long)]
pub kind: Option<String>,
}
#[derive(Debug, Clone, Args)]
pub struct SizeArgs {
#[arg(long)]
pub top: Option<usize>,
}