use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(
name = "pdf-oxide",
version,
about = "Fast, local PDF processing",
long_about = "pdf-oxide — the fastest PDF toolkit.\nRun with no arguments for interactive REPL mode."
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Command>,
#[arg(short, long, global = true)]
pub output: Option<PathBuf>,
#[arg(short, long, global = true)]
pub pages: Option<String>,
#[arg(short, long, global = true)]
pub verbose: bool,
#[arg(short, long, global = true)]
pub quiet: bool,
#[arg(short, long, global = true)]
pub json: bool,
#[arg(long, global = true)]
pub password: Option<String>,
#[arg(long, global = true)]
pub no_banner: bool,
}
#[derive(Subcommand)]
pub enum Command {
Text {
file: PathBuf,
#[arg(long, value_parser = ["plain", "words", "lines"], default_value = "plain")]
format: String,
#[arg(long)]
area: Option<String>,
},
Paths {
file: PathBuf,
#[arg(long, value_parser = ["json", "rects", "lines"], default_value = "json")]
format: String,
#[arg(long)]
area: Option<String>,
},
Markdown {
file: PathBuf,
},
Html {
file: PathBuf,
},
Info {
file: PathBuf,
},
Merge {
#[arg(required = true, num_args = 2..)]
files: Vec<PathBuf>,
},
Split {
file: PathBuf,
},
Create {
file: PathBuf,
#[arg(long, value_parser = ["markdown", "html", "text"])]
from: String,
},
Compress {
file: PathBuf,
},
Encrypt {
file: PathBuf,
},
Decrypt {
file: PathBuf,
#[arg(long)]
password: String,
},
Search {
file: PathBuf,
pattern: String,
#[arg(short, long)]
ignore_case: bool,
},
Images {
file: PathBuf,
#[arg(long)]
area: Option<String>,
},
Rotate {
file: PathBuf,
#[arg(long)]
degrees: i32,
},
Delete {
file: PathBuf,
},
Reorder {
file: PathBuf,
#[arg(long)]
order: String,
},
Metadata {
file: PathBuf,
#[arg(long)]
title: Option<String>,
#[arg(long)]
author: Option<String>,
#[arg(long)]
subject: Option<String>,
#[arg(long)]
keywords: Option<String>,
#[arg(long)]
strip: bool,
},
Watermark {
file: PathBuf,
text: String,
#[arg(long, default_value = "0.3")]
opacity: f32,
#[arg(long, default_value = "45")]
rotation: f32,
#[arg(long, default_value = "48")]
font_size: f32,
#[arg(long)]
color: Option<String>,
},
Bookmarks {
file: PathBuf,
},
Flatten {
file: PathBuf,
#[arg(long)]
forms: bool,
#[arg(long)]
annotations: bool,
},
Crop {
file: PathBuf,
#[arg(long)]
margins: String,
},
Forms {
file: PathBuf,
#[arg(long)]
fill: Option<String>,
#[arg(long, value_parser = ["fdf", "xfdf"])]
export: Option<String>,
#[arg(long)]
area: Option<String>,
},
Render {
file: PathBuf,
#[arg(long, default_value = "150")]
dpi: u32,
#[arg(long, value_parser = ["png", "jpeg"], default_value = "png")]
format: String,
#[arg(long, default_value = "85")]
quality: u8,
},
}