refactor!: lib/bin split, absolute path resolution, and custom path support#89
Open
fractuscontext wants to merge 15 commits intocafkafk:mainfrom
Open
refactor!: lib/bin split, absolute path resolution, and custom path support#89fractuscontext wants to merge 15 commits intocafkafk:mainfrom
fractuscontext wants to merge 15 commits intocafkafk:mainfrom
Conversation
- Refactor `cli.rs` docs to demonstrate `ArgAction::Count` usage. - Update `fortune.rs` examples (`search_fortunes`, `get_quote`) to use `tempfile` and `env::set_var` instead of relying on system files. - Ensure examples are self-contained and testable.
- Uncomment integration tests in `fortune.rs`. - Use `tempfile` to create isolated test environments. - Inject `FORTUNE_DIR` into child processes to prevent CI failures. - Verify `u8` overflow logic for the humorous message easter egg.
- Create `src/lib.rs` to export modules (`cli`, `fortune`, `file`, `random`). - Update `src/main.rs` to consume the crate as a library rather than declaring modules locally. - Enable better separation of concerns, allowing for future integration tests and documentation generation.
- Added detailed CommonMark docstrings for `random` and `get_random_file_weighted`. - Implemented a statistical weighted-selection test using `tempfile`. - Added a test case for single-file path resolution. - Improved error handling in `get_random_file_weighted` to return `io::Error` instead of crashing on empty selections.
- Split project into library (`src/lib.rs`) and binary (`src/main.rs`). - Update `fortune` logic to accept `PathBuf` instead of internal env var lookups. - Implement absolute path resolution in `main` using `fs::canonicalize` and `CARGO_MANIFEST_DIR` defaults. - Add explicit existence check for fortune paths to prevent runtime panics. - Fix `clap` v4 panic by setting `ArgAction::SetTrue` for boolean flags. - Add support for positional path arguments (Closes cafkafk#88)."
- Convert REUSE configuration to `REUSE.toml`. - Update `CHANGELOG.md` via `git-cliff`. - Refresh license headers using `reuse` tool.
- Update installation guide for Nix Flakes and Cargo. - Add comprehensive build instructions, detailing the Nix wrapper and `FORTUNE_DIR` logic. - Document new CLI usage patterns, including short flags (`-ss`), unkind mode (`-u`), and custom paths. - Fix broken badge links and update project metadata.
- Bump package version in `Cargo.toml` and sync `Cargo.lock`. - Update `CHANGELOG.md` with the latest changes via git-cliff.
- Create .github/pull_request_template.md. - Include checklists for Nix builds, Rust testing (clippy/fmt/test), and license compliance (reuse). - Establish guidelines for Conventional Commits and Title Prefixes.
Author
|
@cafkafk Hi! could you please review the changes? :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog Entry
Added
[PATH]argument to load custom fortune files or directories.FORTUNE_OFF_DIRsupport in the Nix wrapper script.random.rs..github/pull_request_template.md).Changed
src/main.rsinto a library (src/lib.rs) and a thin binary wrapper.search_fortunesto return all matching quotes in a file rather than just the first.get_quotenow falls back to a random quote if no "short" fortunes are found, preventing panics.--setinstead of--prefixfor environment variables to match RustPathBuflogic.tempfileexamples.Fixed
clapv4 by setting explicitArgAction::SetTruefor boolean flags.--shortflag to correctly accumulate counts (e.g.,-ss).CARGO_MANIFEST_DIR.%delimiters in fortune files.Breaking Changes
search_fortunesandget_quotenow require aPathBufand no longer perform internal environment variable lookups.Additional Information
CHANGELOG.mdviagit-cliff.Verification & Testing
I have performed the following tests to verify my changes:
Automated Checks
nix buildand verified the./resultsymlink was created successfully.cargo test(ornix build .#test) and all tests passed.cargo clippyand ensured no warnings were introduced.cargo fmtto ensure code style consistency.reuse lintto verify copyright and license headers.Manual Verification
./result/bin/fortune-kind) and verified basic functionality.Build Platform
Pre-Submission Checklist
Before submitting, please ensure the following:
mainbranch.EDITORIAL.md) if necessary.Cargo.tomlandflake.nixif I added new dependencies.git-cliffcan auto-generate the changelog.License Agreement
reuse.