Skip to content

fix: #2 handle missing config file gracefully#56

Open
tarai-dl wants to merge 1 commit intoApexOpsStudio:mainfrom
tarai-dl:az/fix-missing-config-crash
Open

fix: #2 handle missing config file gracefully#56
tarai-dl wants to merge 1 commit intoApexOpsStudio:mainfrom
tarai-dl:az/fix-missing-config-crash

Conversation

@tarai-dl
Copy link
Copy Markdown

What does this PR do?

Fixes #2 — the app no longer crashes when ~/.config/task-cli/config.yaml is missing.

Changes

  • load_config() now checks if config file exists before opening
  • If missing, creates a default config file automatically (mirrors config.yaml.example)
  • Creates parent directories if needed with mkdir(parents=True, exist_ok=True)
  • Added .gitignore for __pycache__/, *.pyc, .pytest_cache/

Tests

  • Added test_load_config_missing_creates_default — verifies default config is created with correct content
  • All 3 tests pass

How to test

# Remove config to simulate missing file
rm -rf ~/.config/task-cli
# Run any command — should not crash
python3 task.py list
# Verify config was created
cat ~/.config/task-cli/config.yaml

Fixes #2

- load_config() now creates default config when file is missing
- Creates config directory automatically if needed
- Added test for missing config scenario
- All 3 tests pass

Fixes ApexOpsStudio#2
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.

Fix: Crash when config file missing

1 participant