Skip to content

Commit 3046322

Browse files
MrFlounderclaude
andauthored
feat(compare): auto-install poppler for PDF support (#64)
## Summary - Adds `compare_ensure_poppler` helper that auto-installs poppler when missing (brew/apt/dnf) - Runs during first-time asset setup (`compare_ensure_assets`) so PDF comparison works out of the box - Also runs on `crab compare --update-assets` to ensure poppler is present - Falls back to a manual install message if no supported package manager is found Follow-up to #63. ## Test plan - [ ] On a machine without poppler: `crab compare file1.pdf file2.pdf` — auto-installs poppler then compares - [ ] `crab compare --update-assets` — re-downloads assets and ensures poppler is installed - [ ] On a machine with poppler already installed — skips install silently 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b27e82b commit 3046322

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/crabcode

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10011,6 +10011,25 @@ compare_pdf_to_text() {
1001110011
fi
1001210012
}
1001310013

10014+
compare_ensure_poppler() {
10015+
if command_exists pdftotext; then
10016+
return 0
10017+
fi
10018+
10019+
echo -e "${CYAN}Installing poppler (for PDF comparison support)...${NC}"
10020+
if [[ "$OSTYPE" == "darwin"* ]] && command_exists brew; then
10021+
brew install poppler || { error "Failed to install poppler via brew."; return 1; }
10022+
elif command_exists apt-get; then
10023+
sudo apt-get install -y poppler-utils || { error "Failed to install poppler-utils via apt."; return 1; }
10024+
elif command_exists dnf; then
10025+
sudo dnf install -y poppler-utils || { error "Failed to install poppler-utils via dnf."; return 1; }
10026+
else
10027+
error "Could not auto-install poppler. Please install 'poppler-utils' manually."
10028+
return 1
10029+
fi
10030+
echo -e "${GREEN}poppler installed${NC}"
10031+
}
10032+
1001410033
compare_ensure_assets() {
1001510034
local version_file="$COMPARE_ASSETS_DIR/.version"
1001610035

@@ -10033,6 +10052,9 @@ compare_ensure_assets() {
1003310052
return 1
1003410053
fi
1003510054

10055+
# Ensure poppler is available for PDF support
10056+
compare_ensure_poppler
10057+
1003610058
echo "$COMPARE_ASSETS_VERSION" > "$version_file"
1003710059
echo -e "${GREEN}Assets downloaded${NC}"
1003810060
}
@@ -10049,7 +10071,9 @@ cmd_compare() {
1004910071
"--update-assets"|"--update")
1005010072
rm -rf "$COMPARE_ASSETS_DIR"
1005110073
compare_ensure_assets
10052-
return $?
10074+
local rc=$?
10075+
compare_ensure_poppler
10076+
return $rc
1005310077
;;
1005410078
esac
1005510079

0 commit comments

Comments
 (0)