use crate::output::OutputFormat;
use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(name = "parqkit")]
#[command(about = "Inspect, convert, and merge Parquet files with fast, script-friendly output.")]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
Schema(SchemaArgs),
Head(HeadArgs),
Tail(TailArgs),
Count(CountArgs),
Stats(StatsArgs),
Convert(ConvertArgs),
Merge(MergeArgs),
Info(InfoArgs),
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, clap::ValueEnum)]
pub enum OutputFormatArg {
#[default]
Table,
Json,
Jsonl,
Csv,
}
impl From<OutputFormatArg> for OutputFormat {
fn from(value: OutputFormatArg) -> Self {
match value {
OutputFormatArg::Table => Self::Table,
OutputFormatArg::Json => Self::Json,
OutputFormatArg::Jsonl => Self::Jsonl,
OutputFormatArg::Csv => Self::Csv,
}
}
}
#[derive(Debug, Args)]
pub struct SchemaArgs {
#[arg(required = true)]
pub inputs: Vec<PathBuf>,
#[arg(short, long, default_value = "table")]
pub output: OutputFormatArg,
#[arg(short, long)]
pub quiet: bool,
}
#[derive(Debug, Args)]
pub struct HeadArgs {
#[arg(required = true)]
pub inputs: Vec<PathBuf>,
#[arg(short = 'n', long = "rows", default_value = "10")]
pub rows: usize,
#[arg(short, long, default_value = "table")]
pub output: OutputFormatArg,
#[arg(short, long)]
pub quiet: bool,
}
#[derive(Debug, Args)]
pub struct TailArgs {
#[arg(required = true)]
pub inputs: Vec<PathBuf>,
#[arg(short = 'n', long = "rows", default_value = "10")]
pub rows: usize,
#[arg(short, long, default_value = "table")]
pub output: OutputFormatArg,
#[arg(short, long)]
pub quiet: bool,
}
#[derive(Debug, Args)]
pub struct CountArgs {
#[arg(required = true)]
pub inputs: Vec<PathBuf>,
#[arg(short, long)]
pub quiet: bool,
}
#[derive(Debug, Args)]
pub struct StatsArgs {
#[arg(required = true)]
pub inputs: Vec<PathBuf>,
#[arg(short, long)]
pub column: Option<String>,
#[arg(short, long, default_value = "table")]
pub output: OutputFormatArg,
#[arg(short, long)]
pub quiet: bool,
}
#[derive(Debug, Args)]
pub struct ConvertArgs {
#[arg(required = true)]
pub input: PathBuf,
#[arg(required = true)]
pub output_path: PathBuf,
}
#[derive(Debug, Args)]
pub struct MergeArgs {
#[arg(required = true)]
pub inputs: Vec<PathBuf>,
#[arg(short, long, required = true)]
pub output: PathBuf,
}
#[derive(Debug, Args)]
pub struct InfoArgs {
#[arg(required = true)]
pub inputs: Vec<PathBuf>,
#[arg(short, long, default_value = "table")]
pub output: OutputFormatArg,
#[arg(short, long)]
pub quiet: bool,
}