Repository navigation
feat(cli): project config file depradar.toml - #230
Merged
ALLEN-AYODEJI merged 2 commits intoOct 20, 2026
Merged
ALLEN-AYODEJI merged 2 commits into
ALLEN-AYODEJI merged 2 commits into
Conversation
Add `src/config.rs` with `ProjectConfig` that loads four keys from a `depradar.toml` in the working directory: - `fail_on` – severity threshold (low/medium/high/critical/none; default high) - `format` – output format (text/json; default text) - `exclude` – glob patterns for lockfile paths to skip - `ecosystems` – restrict scanning to specific ecosystems Precedence: built-in defaults ← depradar.toml ← CLI flags. A missing file is a no-op; an invalid file exits 2 with a clear error. Unknown TOML keys are rejected via `deny_unknown_fields`. Wire into `src/bin/depradar.rs`: - Load config from CWD in `main()` before dispatch - `ResolvedConfig::resolve()` merges defaults ← file ← CLI flags - `--fail-on`, `--exclude`, `--ecosystem` flags now documented and active - `--format` made optional so the file can supply the default Tests (src/config.rs unit + tests/cli.rs integration): - FailOn ordering and round-trip FromStr/Display for all three enums - Full config TOML parse, empty-file, unknown-key rejection - load_project_config returns None when absent, errors on bad TOML - CLI precedence: format/fail_on/exclude each: file < CLI flag - fail_on=none exits 0 with findings; invalid config exits 2 Docs: README updated with depradar.toml section, key reference table, and updated CLI options table. PROGRESS.md entry added. Closes DepRadarOrg#85
|
@jolesonbethany1-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Closes #85
Teams want the same flags every run (threshold, ignored paths, format) without retyping them. This PR adds
depradar.toml— a per-project config file that supplies defaults for every repeatable CLI flag. CLI flags always win, so existing scripts and one-off commands are unaffected.What was built
src/config.rs(new file) — typed config loader:ProjectConfigstruct with four optional keys:fail_on,format,exclude,ecosystemsFailOnenum (orderedNone < Low < Medium < High < Critical, defaultHigh)ConfigEcosystemenum (npm/pypi/cargo/go/maven/rubygems/packagist, lowercase + canonical aliases)ConfigFormatenum (text/json)load_project_config(dir)— returnsOk(None)when absent,Erron parse failure;deny_unknown_fieldsrejects typossrc/bin/depradar.rs— config wired into the CLI:load_project_config(&cwd)called inmain()before dispatch; invalid file → exit 2ResolvedConfig::resolve()merges: built-in defaults ←depradar.toml← CLI flags--fail-on,--exclude,--ecosystemflags are now documented and fully active--formatmadeOption<Format>so the config file can supply itsrc/lib.rs—pub mod configaddedFile format
All keys are optional. An empty
depradar.tomlis valid. Unknown keys are rejected with a parse error pointing to the file.Tests
Unit tests in
src/config.rs:FailOnordering (None < Low < … < Critical)FromStr/DisplayforFailOn,ConfigEcosystem,ConfigFormatProjectConfigload_project_configreturnsNonewhen no file existsErron malformed TOMLIntegration tests in
tests/cli.rs(precedence tests per acceptance criteria):config_file_format_json_is_used_when_no_flag— file value used when no CLI flagcli_format_flag_overrides_config_file— CLI flag wins over fileconfig_file_fail_on_none_exits_zero_even_with_findings— file value appliedcli_fail_on_flag_overrides_config_file_none— CLI flag wins over fileconfig_file_exclude_skips_matching_paths— file value appliedcli_exclude_flag_overrides_config_file— CLI flag wins over filemissing_config_file_uses_defaults— no file → built-in defaultsinvalid_config_file_exits_with_code_2— bad file → exit 2 + error mentionsdepradar.tomlAll 146 tests pass.
cargo fmt --check,cargo clippy -- -D warnings, andcargo test -p depraderall green.Docs
README.md— new### Project config file (depradar.toml)section with annotated example and key reference table; updated CLI options table reflecting newly active flagsPROGRESS.md— entry added per the Definition of Done inCONTRIBUTING.mdChecklist
cargo fmt,cargo clippy -- -D warningsandcargo test --workspacepassPROGRESS.mdentry addedCloses #85in this description