2.4 KiB
+++ title = "Add .nbd/config.toml for per-project defaults" priority = 5 status = "todo" ticket_type = "feature" dependencies = [] +++
Problem
All defaults (output format, file type, default status) are hard-coded in the CLI. Users in a project that always uses --json or always creates md-format tickets must pass these flags repeatedly. A per-project config file would let them set these once.
Config file
Location: .nbd/config.toml (inside the .nbd/ root, alongside tickets/ and cache.db).
Format (all keys optional — missing keys fall back to compiled defaults):
[nbd]
json = false # default: false — use tabular output
ftype = "json" # default: "json" — ticket storage format
status = "todo" # default: "todo" — initial status for new tickets
Precedence (highest to lowest)
- Explicit CLI flag (e.g.,
--json,--ftype md) - Environment variable (not in scope for this ticket)
.nbd/config.toml- Compiled-in default
Implementation
src/store.rs (or a new src/config.rs)
Add a NbdConfig struct and a load_config(root: &Path) -> NbdConfig function:
pub struct NbdConfig {
pub json: bool,
pub ftype: FileFormat,
pub status: Status,
}
impl Default for NbdConfig { /* compiled-in defaults */ }
pub fn load_config(root: &Path) -> NbdConfig { /* read .nbd/config.toml, fall back to Default */ }
Parse with the toml crate (already in Cargo.toml). Errors in the config file should produce a helpful message to stderr and fall back to defaults rather than aborting.
src/main.rs — dispatch()
After find_nbd_root(), call load_config. Merge config values with CLI flags:
cli.json = cli.json || config.json(CLI flag wins)- For
--ftype: if the user did not pass--ftype, useconfig.ftype - For
--statusincreate: if the user did not pass--status, useconfig.status
src/main.rs — cmd_init
After creating the tickets directory, write .nbd/config.toml with default values if it does not already exist.
tests/integration.rs
- Test that a config with
json = truecauses tabular commands to emit JSON. - Test that a config with
ftype = "md"causescreateto write.mdfiles. - Test that explicit CLI flags override config values.
- Test idempotency of
nbd init(does not overwrite existing config).
Dependencies
None. Can be implemented independently of other tickets.