use std::path::PathBuf;
use std::process::ExitCode;
use clap::{Parser, Subcommand};
use pdf_untangle::profile;
#[derive(Parser)]
#[command(
name = "pdf-untangle",
version,
about = "Untangle garbled PDF text into structured sections"
)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
Extract {
pdf: PathBuf,
#[arg(long)]
profile: String,
#[arg(short, long)]
out: Option<PathBuf>,
},
Text { pdf: PathBuf },
Inspect {
pdf: PathBuf,
#[arg(long, default_value_t = 1)]
page: u32,
},
Profiles,
Check {
pdf: PathBuf,
#[arg(long)]
profile: String,
},
}
fn main() -> ExitCode {
let cli = Cli::parse();
match cli.command {
Command::Profiles => {
for name in profile::builtin_names() {
match profile::Profile::builtin(name) {
Ok(p) => {
let draft = if p.draft {
" (draft — citation template pending sign-off)"
} else {
""
};
println!(
"{name}: {} / {} — \"{}\"{draft}",
p.jurisdiction, p.kind, p.citation_template
);
}
Err(e) => eprintln!("{name}: BROKEN — {e:#}"),
}
}
ExitCode::SUCCESS
}
Command::Extract { .. }
| Command::Text { .. }
| Command::Inspect { .. }
| Command::Check { .. } => {
eprintln!(
"not implemented yet: this subcommand lands with Phases 1-3 (docs/DESIGN.md). \
The scaffold currently ships the profile system and output model only."
);
ExitCode::from(2)
}
}
}