Skip to content

fix: create default config when missing instead of crashing (closes #2)#23

Open
chengfei-gh wants to merge 1 commit intoApexOpsStudio:mainfrom
chengfei-gh:fix/missing-config-crash
Open

fix: create default config when missing instead of crashing (closes #2)#23
chengfei-gh wants to merge 1 commit intoApexOpsStudio:mainfrom
chengfei-gh:fix/missing-config-crash

Conversation

@chengfei-gh
Copy link

Fix for #2: Crash when config file missing

Problem

python task.py list crashes with FileNotFoundError when ~/.config/task-cli/config.yaml doesn't exist.

Solution

load_config() now automatically creates a default config file if missing:

  • Creates ~/.config/task-cli/ directory if needed
  • Writes sensible defaults matching config.yaml.example
  • Prints helpful message: [task-cli] Created default config at ...

Changes

  • Modified load_config() in task.py with graceful config creation
  • Added DEFAULT_CONFIG constant with default settings

Testing

# Remove config and verify no crash
rm -rf ~/.config/task-cli/
python task.py list   # Creates default config, lists tasks (empty)

# Verify default config was created
cat ~/.config/task-cli/config.yaml

Acceptance Criteria

  • No crash when config file is missing
  • Creates sensible default config
  • Shows clear message about config creation
  • All existing tests pass

Payment

Solana wallet: CZkLs4m55JBffoowGUtyfqb5GrymUVxgr9kMTrXKfbJV

Fixes ApexOpsStudio#2

Changes:
- load_config() now creates default config.yaml if missing
- Creates ~/.config/task-cli/ directory if it doesn't exist
- Prints helpful message when creating default config
- Uses sensible defaults matching config.yaml.example

Previously: FileNotFoundError with ugly stack trace
Now: Creates config automatically and continues

Tests:
- rm ~/.config/task-cli/config.yaml && python task.py list → works
- All existing tests still pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant