`pdfcraft-cli audit` skipped option validation, so a misspelled `--passwrod` fell through to a file-read error instead of naming the bad option. Audit now runs `validate_options` first, like `info`, and the options test covers it. Co-authored-by: umesh429 <3474974+umesh429@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ec5d9da36c
commit
27ce6f7584
|
|
@ -151,6 +151,7 @@ fn version() -> Result<(), CliError> {
|
|||
/// Audit a document for faux redactions. Prints the findings as JSON; fails when any are
|
||||
/// found so scripts and CI can gate on it, and when the audit itself cannot run.
|
||||
fn audit(args: &[String]) -> Result<(), CliError> {
|
||||
validate_options("audit", args, AUDIT_OPTIONS)?;
|
||||
let path = *positional(args).first().ok_or("audit: missing file")?;
|
||||
let bytes = read(path)?;
|
||||
let doc = pdfcraft_cos::Document::open_with_password(bytes, flag(args, "--password")).map_err(|e| format!("{path}: {e}"))?;
|
||||
|
|
@ -213,6 +214,7 @@ fn validate_options(command: &str, args: &[String], specs: &[OptionSpec]) -> Res
|
|||
}
|
||||
|
||||
const INFO_OPTIONS: &[OptionSpec] = &[OptionSpec { name: "--password", takes_value: true }];
|
||||
const AUDIT_OPTIONS: &[OptionSpec] = &[OptionSpec { name: "--password", takes_value: true }];
|
||||
const TEXT_OPTIONS: &[OptionSpec] = &[OptionSpec { name: "--page", takes_value: true }, OptionSpec { name: "--password", takes_value: true }];
|
||||
const COMBINE_OPTIONS: &[OptionSpec] = &[OptionSpec { name: "--out", takes_value: true }];
|
||||
const EXTRACT_OPTIONS: &[OptionSpec] = &[
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ fn non_edit_commands_reject_unknown_options_before_io() {
|
|||
vec!["render", "missing.pdf", "--dppi", "96", "--out", "out.png"],
|
||||
vec!["check-one", "missing.pdf", "--edti"],
|
||||
vec!["check", "missing.pdf", "--timout", "2"],
|
||||
vec!["audit", "missing.pdf", "--passwrod", "x"],
|
||||
vec!["audit", "missing.pdf", "--nonsense", "1"],
|
||||
vec!["run", "doc_open", "--roto", "/tmp"],
|
||||
vec!["ui", "--contro", "control.json", "state"],
|
||||
] {
|
||||
|
|
|
|||
Loading…
Reference in New Issue