use std::path::PathBuf;
use clap::{Parser, ValueEnum};
#[derive(Debug, Parser)]
#[command(
name = "rllvm-query",
about = "Query captured bitcode at source level",
after_help = "With --catalog and no query, reads one query per line from stdin, \
written as on the command line, and answers them all from one load \
of the catalog.",
version
)]
pub struct QueryArgs {
#[arg(long = "llvm-version")]
pub llvm_version: bool,
#[arg(long)]
pub catalog: Option<PathBuf>,
#[arg(long, global = true)]
pub heuristics: bool,
#[arg(long, global = true, conflicts_with = "full")]
pub json: bool,
#[arg(long, global = true)]
pub full: bool,
#[command(subcommand)]
pub command: Option<QueryCommand>,
}
#[derive(Clone, Copy, Debug, ValueEnum)]
pub enum ClosureDirection {
In,
Out,
}
#[derive(clap::Subcommand, Debug)]
#[command(rename_all = "kebab-case")]
pub enum QueryCommand {
Defs {
name: String,
},
At {
file: String,
line: u32,
},
Callers {
name: String,
},
Callees {
name: String,
},
Uses {
name: String,
},
Reach {
from: String,
to: String,
},
Closure {
name: String,
#[arg(value_enum)]
direction: ClosureDirection,
},
Externals,
FfiExports,
IndirectTargets {
at: String,
},
Mcp,
Completions {
#[arg(value_enum)]
shell: clap_complete::Shell,
},
Cache {
#[command(subcommand)]
action: Option<CacheAction>,
},
}
#[derive(clap::Subcommand, Debug)]
pub enum CacheAction {
Clear {
#[arg(long)]
stale: bool,
},
}