use clap::{Args, Parser as ClapParser, Subcommand};
use std::path::PathBuf;
#[derive(ClapParser, Debug)]
#[command(
name = "jsonette",
version = "0.4.0",
about = "Fast, lightweight JSON format, query, and configuration utility."
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Format(FormatArgs),
Query(QueryArgs),
Explore(ExploreArgs),
Generate(GenerateArgs),
Config(ConfigArgs),
Convert(ConvertArgs),
Completions {
#[arg(value_enum)]
shell: clap_complete::Shell,
},
}
#[derive(Args, Debug)]
pub struct FormatArgs {
pub file: Option<PathBuf>,
#[arg(short = 'm', long)]
pub minify: bool,
#[arg(short = 's', long)]
pub sort_keys: Option<bool>,
#[arg(short = 'n', long)]
pub indent: Option<u8>,
#[arg(long)]
pub use_tabs: Option<bool>,
#[arg(long, value_parser = ["lf", "crlf"])]
pub line_ending: Option<String>,
#[arg(long, value_parser = ["expanded", "compact"])]
pub folding_style: Option<String>,
#[arg(short = 'o', long)]
pub output: Option<PathBuf>,
#[arg(short = 'i', long)]
pub in_place: bool,
}
#[derive(Args, Debug)]
pub struct QueryArgs {
pub query: String,
pub file: Option<PathBuf>,
}
#[derive(Args, Debug)]
pub struct ExploreArgs {
pub path: String,
pub file: Option<PathBuf>,
#[arg(short = 'g', long)]
pub grep: Option<String>,
#[arg(short = 'r', long)]
pub regex: Option<String>,
#[arg(short = 'n', long)]
pub limit: Option<usize>,
}
#[derive(Args, Debug)]
pub struct GenerateArgs {
#[arg(short = 's', long, conflicts_with = "count")]
pub size: Option<usize>,
#[arg(short = 'n', long, conflicts_with = "size")]
pub count: Option<usize>,
#[arg(short = 'c', long)]
pub schema: Option<PathBuf>,
#[arg(short = 'o', long)]
pub output: Option<PathBuf>,
#[arg(short = 'm', long)]
pub minify: bool,
}
#[derive(Args, Debug)]
pub struct ConfigArgs {
#[command(subcommand)]
pub command: ConfigCommands,
}
#[derive(Subcommand, Debug)]
pub enum ConfigCommands {
List,
Get {
key: String,
},
Set {
key: String,
value: String,
},
}
#[derive(Args, Debug)]
pub struct ConvertArgs {
#[arg(short = 'f', long, default_value = "json")]
pub from: String,
#[arg(short = 't', long, default_value = "yaml")]
pub to: String,
pub file: Option<PathBuf>,
}