- 🧮 Persistent interactive mode
- When run without flags or piped input,
diffsquarenow enters a continuous interactive loop. - Prompts for a modulus, factors it, then prompts again — until the user types
exitorquit. - Greatly improves usability for exploratory or classroom-style usage.
- When run without flags or piped input,
- ✅ Improved piped input support
- Automatically reads full stdin when piped input is detected.
- Handles multi-line inputs split by backslashes (e.g.,
bcoutput). - Enhances scriptability and integration with tools like
bc,openssl, etc.
-
✅ Clarified
--threadsbehavior--threadsnow explicitly applies only in--stdinor--inputmodes for batch factorization.- Removed misleading claim that default is 1; default follows Rayon’s default (number of logical CPUs).
- Updated help text and README for accuracy.
-
✅ Improved input handling
- Prevents unintended interactive prompts when input is piped without
--stdinor--input. - Better error reporting when no modulus is provided in quiet, JSON, CSV, or time-only modes.
- Prevents unintended interactive prompts when input is piped without
-
📝 Documentation
- Updated internal comments for clarity.
- Adjusted README to reflect actual
--threadsbehavior.
-
✅
--input <FILE>flag- Allows reading newline-separated numbers from a specified file.
- Supports batch factorization of large input sets via file input.
- Fully compatible with
--json,--csv,--quiet,--time-only, and output file modes. - Can be combined with
--threadsto enable parallel factorization.
-
✅ Thread pool configuration for file or stdin input
- Supports
--threads Nto control the number of Rayon threads for batch factorization. - Ensures better performance tuning for large input sets.
- Supports
- 🚀 Progress bar enhancements
- Displays progress for file and stdin input only when not in quiet, json, csv, or time-only mode.
- Cleaner, more informative progress display using
indicatif.
- ✅ Optional
--timeout Nflag to limit maximum time per factorization in milliseconds. - ✅ CSV output support via
--csvflag for easy integration with spreadsheets.
✅ --output FILE flag
- Allows saving factorization results to a specified file.
- Supports both plain text and JSON output (respects
--jsonif set). - Appends results to the file if it already exists.
-
🚀 Rayon parallelism ready
- Integrated
rayon = "1.10.0"dependency for future parallel optimizations. - Prepares the codebase for multithreaded factorization of large inputs or batch jobs.
- Integrated
- ⬆️ Version bump:
diffsquarenow at 0.5.0 to reflect API evolution and groundwork for concurrency.
-
🐛 Bug fix for
--stdinmode:- Precision was defaulting to
0when not explicitly provided, causing a runtime panic. - Now defaults to a safe value (
30) if--stdinis used without--prec. - Ensures seamless batch input even without verbose precision.
- Precision was defaulting to
-
✅ New CLI feature:
--stdinflag- Accepts multiple newline-separated numbers from standard input (stdin).
- Enables batch factorization via piping or redirection.
- Compatible with scripting workflows across shells.
- Fully integrates with
--quiet,--json, and--time-onlymodes.
-
✅ New test suite for large semiprimes:
- Introduced
big_numberstest containing 15 products of two 31-bit primes. - Ensures accurate factorization for moderately large integers.
- Helps verify algorithm correctness and performance under larger inputs.
- Introduced
-
--time-onlyflag: print only execution time after successful factorization.- Does not show factors or prompts.
- Designed for benchmarking and performance testing.
- Mutually exclusive with
--json.
| Mode | Prompts | Shows Factors | Shows Time | Use Case |
|---|---|---|---|---|
| Default | ✅ | ✅ | ✅ | General purpose |
--quiet |
❌ | ✅ | ❌ | Clean CLI output |
--json |
❌ | ✅ (JSON) | ✅ (JSON) | Scriptable automation |
--time-only |
❌ | ❌ | ✅ | Performance benchmarking |
-
--jsonflag: output factorization results as JSON (suppresses all other output).- Includes "modulus", "p", and "q" fields.
- Outputs a JSON error message if factorization fails.
- Designed for scripting, automation, and programmatic integration.
- Suppressed execution time and verbose output when
--jsonis active. - Improved internal branching logic for mutually exclusive quiet and JSON modes.
-
Refined CLI experience:
- Improved help messages, usage examples, and argument prompts.
- More intuitive fallback behavior when partial arguments are provided.
- Clean separation of prompt logic—interactive and quiet modes now behave more predictably.
-
Internally cleaned up CLI parsing flow without changing existing features.
- CLI logic improved:
-p(precision) is no longer required in--quietmode. - Default starting iteration (
1) is used in--quietmode if-iis not provided. - The
input()function no longer checks the--quietflag internally; this is now handled only where necessary (e.g., for modulus input).
- Graceful handling of missing parameters in
--quietmode using sensible defaults where possible.
- Added quiet mode (
-q,--quiet) - Show execution time after factorization
- Removed default modulus value; now prompted interactively if not provided via
-n/--mod - Introduced
clapfor structured and user-friendly command-line argument parsing - Updated README usage examples to reflect removal of default modulus and clarify argument use