id: task-4.13 title: 'CLI: Fix config command local/global logic' status: Done assignee: [] created_date: '2025-06-09' updated_date: '2025-06-09' labels: [] dependencies: [] parent_task_id: task-4
Description
Fix config commands to correctly use local or global config files
Acceptance Criteria
- [x]
backlog config set <key> <value> --localsaves changes to.backlog/config.yml. - [x]
backlog config set <key> <value> --globalsaves changes to the user config file. - [x]
backlog config get <key>checks local config first, then global config, then defaults. - [x] Behavior prioritizes local configuration over global and built-in defaults.
- [x] Documentation updated to describe local and global configuration behavior.
Implementation Notes
CLI Command Implementation (src/cli.ts:497-548):
- Added
config get <key>command that implements proper priority order: local config → global config → built-in defaults - Added
config set <key> <value>command with--localand--globalflags --localflag (default behavior) saves to.backlog/config.ymlin current project--globalflag saves to~/.backlog/.userin user's home directory- Built-in defaults include
statuses: ["Draft", "To Do", "In Progress", "Done"]anddefaultStatus: "To Do"
FileSystem Implementation (src/file-system/operations.ts:349-392):
- Added
getUserSetting(key, global)method to read from user config files - Added
setUserSetting(key, value, global)method to write to user config files - Global config stored in
~/.backlog/.user(home directory) - Local config stored in
./.user(project directory) - Supports key-value format with colon separation and optional quotes
- Fixed
serializeConfig()andsaveUserSettings()to always include trailing newlines for proper file formatting
Configuration Priority Logic:
- Local config first: Checks
.backlog/config.ymlfor project-specific settings - Global config fallback: Checks
~/.backlog/.userfor user-wide settings - Built-in defaults: Falls back to hardcoded values for core settings like statuses
Documentation Updates (README.md:176-179):
- Added explanation of
--local(default) and--globalflags - Documented priority order: local → global → defaults
- Updated usage examples to show flag usage
- Clarified behavior for both
config getandconfig setcommands
Quality Assurance:
- All filesystem tests pass, including new user config operations test
- Manual testing confirms proper flag behavior and priority order
- CLI help text includes proper flag documentation
- Implementation maintains backward compatibility with existing config operations
The config commands now correctly handle local/global configuration with proper precedence rules, enabling users to maintain both project-specific and user-wide settings.