Skip to content

Conversation

Copy link

Copilot AI commented Aug 22, 2025

This PR adds support for a --dictionary CLI argument that allows users to provide a newline-separated text file containing search needles, as requested in the issue.

Changes Made

  • Added clap dependency with derive features for argument parsing
  • Introduced a new Args struct using clap's derive API to handle CLI arguments
  • Modified gather_needles() function to accept both dictionary files and CLI arguments
  • Maintained full backward compatibility with existing CLI usage
  • Added proper error handling for file reading and validation

Usage Examples

Using a dictionary file:

cargo run -- --dictionary words.txt

Using CLI arguments (existing behavior):

cargo run -- hello world test

Combining both approaches:

cargo run -- --dictionary words.txt extra additional

Implementation Details

The dictionary file is processed with the same preprocessing steps as CLI arguments:

  • Converts all words to lowercase
  • Removes whitespace from words
  • Deduplicates the final set of needles
  • Filters out empty strings

Error handling includes:

  • Clear error messages for missing dictionary files
  • Validation that at least one needle is provided (either via file or CLI)
  • Graceful handling of empty dictionary files

The implementation preserves all existing functionality while adding the new dictionary mode as requested.

Fixes #4.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI assigned Copilot and cfm Aug 22, 2025
Copy link
Author

Copilot AI commented Aug 22, 2025

@cfm 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI changed the title [WIP] dictionary mode: ingest word list as needles Add --dictionary CLI argument to ingest word list from file Aug 22, 2025
Copilot AI requested a review from cfm August 22, 2025 22:47
Copilot finished work on behalf of cfm August 22, 2025 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dictionary mode: ingest word list as needles

2 participants