refactor(args): make --config an Option instead of a hardcoded default#1584
refactor(args): make --config an Option instead of a hardcoded default#1584lazizbekravshanov wants to merge 2 commits into
Conversation
Replace the `cliff.toml` clap default with `config: Option<PathBuf>` so an explicitly supplied `--config` is distinguishable from automatic discovery (follow-up to the orhun#1182 discussion). Behavior is preserved: when `--config` is omitted, resolution falls back to the default file name and follows the existing discovery order (project config -> user config directory -> built-in default), `.config/cliff.toml` discovery still works, and `--init` still targets cliff.toml. `init_config` is simplified to take an `Option` accordingly.
|
Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️ |
|
Hey! Yes, I think we should enable discovery when the Also, can you update the docs based on this changes? |
Per review on orhun#1584: when `--config` is not given, resolve the configuration purely through discovery — a project `cliff.toml` / `.cliff.toml` / `.config/cliff.toml` (searched up the directory tree), then the user configuration directory — instead of front-loading a hardcoded `cliff.toml`. An explicit `--config` (path or built-in template name) still overrides discovery. Update the configuration docs accordingly.
|
Done in 329e753 👍 When Also updated the docs (Configuration → File Path). Verified behaviorally: implicit |
|
Hi @orhun — following up on this one 🙂 I implemented the discovery-when- (The two red checks are infra-only: "Test suite" is the Codecov-upload GPG flake and "Links" is GitLab returning 403s to the CI runner — both fail intermittently on |
Description
Replaces the hardcoded
cliff.tomlclap default for--configwithconfig: Option<PathBuf>, so an explicitly-supplied--configis distinguishable from automatic discovery.--configno longer advertises[default: cliff.toml]in--help.init_configis simplified to take anOption<&Path>(dropping theif config_path == DEFAULT_CONFIG { … }special-case).Behavior is intentionally preserved — this is a type/clarity cleanup, not a behavior change:
--configis omitted, resolution falls back to the default file name and keeps the existing discovery order (projectcliff.toml→ user config directory → manifest → project discovery → built-in default)..config/cliff.tomldiscovery (feat: support more configuration files #1448) still works.--config <path>,--config <builtin-name>(e.g.detailed), and--init [--config <path>]all behave exactly as before.Motivation and Context
Follow-up to the discussion in #1182 — @joshka suggested (and @orhun agreed) that the clap default should be an
Optionrather than a hardcoded value. This is the minimal cleanup for that.One open question for you, @orhun: I kept the resolution order identical for safety, which means with
--configomitted the implicitcliff.tomlis still checked before the user config directory (unchanged behavior). If you'd prefer theNonecase to route through pure discovery instead (which would slightly change the project-cliff.toml-vs-user-config precedence), I'm happy to do that in a follow-up — just wanted to avoid changing precedence without your sign-off, since you'd mentioned wanting to discuss theclapusage.How Has This Been Tested?
cargo test(workspace): all green.cargo +nightly fmt --all -- --checkandcargo clippy --tests -- -D warnings: clean on the changed code.cliff.toml, explicit--config custom.toml,.config/cliff.tomldiscovery,--config detailed(built-in),--init, and--init --config custom.toml— all behave as before;--helpno longer shows the default.Types of Changes
Checklist:
cargo +nightly fmt --allcargo clippy --tests --verbose -- -D warningscargo test