use std::path::PathBuf;
use clap::{Parser, Subcommand};
#[derive(Debug, Subcommand)]
pub enum Command {
Skill,
Index {
#[arg(required = true)]
paths: Vec<PathBuf>,
#[arg(short, long)]
output: Option<PathBuf>,
},
Query {
query: String,
#[arg(long)]
index: PathBuf,
},
}
#[derive(Debug, Parser)]
#[command(
version,
about,
disable_help_flag = true,
subcommand_negates_reqs = true,
subcommand_precedence_over_arg = true,
after_help = "Examples:\n geg 'release a resource' src/\n cat notes.txt | geg 'travel plans'\n printf 'authentication\\nretry logic\\n' | geg --interactive src/\n\nExit codes: 0 = matches, 1 = no matches, 2 = error.\nModel: text-only EmbeddingGemma 2 GGUF; set GEG_MODEL or --model."
)]
pub struct Args {
#[command(subcommand)]
pub command: Option<Command>,
#[arg(long, action = clap::ArgAction::Help)]
help: Option<bool>,
#[arg(short = 'q', long, alias = "silent", global = true)]
pub quiet: bool,
#[arg(long, global = true)]
pub no_index_hint: bool,
#[arg(short = 's', long = "no-messages", global = true)]
pub no_messages: bool,
#[arg(short = 'e', long = "regexp", action = clap::ArgAction::Append)]
pub patterns: Vec<String>,
#[arg(short = 'f', long = "file", action = clap::ArgAction::Append)]
pub pattern_files: Vec<PathBuf>,
#[arg(short = 'r', long = "recursive")]
pub recursive: bool,
#[arg(short = 'R', long = "dereference-recursive")]
pub dereference_recursive: bool,
#[arg(short = 'i', long = "ignore-case", global = true)]
pub ignore_case: bool,
#[arg(short = 'v', long = "invert-match", global = true)]
pub invert_match: bool,
#[arg(short = 'n', long = "line-number", global = true)]
pub line_number: bool,
#[arg(
short = 'H',
long = "with-filename",
overrides_with = "no_filename",
global = true
)]
pub with_filename: bool,
#[arg(
short = 'h',
long = "no-filename",
overrides_with = "with_filename",
global = true
)]
pub no_filename: bool,
#[arg(short = 'c', long, global = true)]
pub count: bool,
#[arg(
short = 'l',
long = "files-with-matches",
overrides_with = "files_without_match",
global = true
)]
pub files_with_matches: bool,
#[arg(
short = 'L',
long = "files-without-match",
overrides_with = "files_with_matches",
global = true
)]
pub files_without_match: bool,
#[arg(short = 'm', long = "max-count", global = true)]
pub max_count: Option<u64>,
#[arg(long, global = true)]
pub score: bool,
#[arg(long, default_value = "(standard input)")]
pub label: String,
#[arg(long, global = true)]
pub line_buffered: bool,
#[arg(required_unless_present_any = ["interactive", "patterns", "pattern_files"])]
pub query: Option<String>,
pub paths: Vec<PathBuf>,
#[arg(long, env = "GEG_MODEL", global = true)]
pub model: Option<PathBuf>,
#[arg(long, env = "GEG_CACHE", global = true)]
pub cache: Option<PathBuf>,
#[arg(long, global = true)]
pub no_cache: bool,
#[arg(long)]
pub interactive: bool,
#[arg(long, global = true)]
pub json: bool,
#[arg(short = 'k', long, global = true, default_value_t = 10, value_parser = clap::value_parser!(u32).range(1..=10000))]
pub top: u32,
#[arg(
long,
global = true,
default_value_t = 0.15,
allow_hyphen_values = true
)]
pub threshold: f32,
#[arg(long, global = true, default_value_t = 8, value_parser = clap::value_parser!(u32).range(1..=128))]
pub chunk_lines: u32,
#[arg(long, global = true, default_value = "256", value_parser = ["128", "256", "512", "768"])]
pub dimensions: String,
#[arg(long, global = true)]
pub code: bool,
#[arg(short = 't', long, global = true, value_parser = clap::value_parser!(u32).range(1..=256))]
pub threads: Option<u32>,
}