-
Notifications
You must be signed in to change notification settings - Fork 1
fix: doctor command auto-detects config and suggests init #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously, doctor always checked /etc/ofelia/config.ini even when a local ./ofelia.ini existed. This was frustrating for users who just ran `ofelia init` and wanted to verify their setup. Changes: - Add config file auto-detection searching: ./ofelia.ini, ./config.ini, /etc/ofelia/config.ini, /etc/ofelia.ini (in priority order) - Suggest `ofelia init` when no config file is found - Show all searched paths in error hints for clarity - Add README documentation for init and doctor commands The doctor command now works seamlessly after running `ofelia init`, improving the getting-started experience.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the doctor command's configuration file discovery and improves the getting-started experience by implementing automatic config file detection and better error messages. The changes address a workflow gap where ofelia init creates ./ofelia.ini but doctor previously only checked /etc/ofelia/config.ini.
Key changes:
- Auto-detection searches 4 common locations in priority order:
./ofelia.ini,./config.ini,/etc/ofelia/config.ini,/etc/ofelia.ini - Error messages now suggest running
ofelia initand display all searched paths - Documentation added for both
initanddoctorcommands in README
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ofelia.go | Removed pre-parsed ConfigFile initialization for DoctorCommand to enable auto-detection |
| cli/doctor.go | Added commonConfigPaths list, findConfigFile() helper, and auto-detection logic in Execute(); updated error hints to suggest ofelia init |
| README.md | Added "Interactive Setup" and "Health Diagnostics" sections documenting init and doctor commands with usage examples |
Address Copilot review feedback: - Fix README: change --config to --output for ofelia init command - Track auto-detection state with configAutoDetected field - Only show "Searched:" hint when auto-detection was attempted - Add comprehensive tests for: - findConfigFile() with priority order verification - Auto-detection finds ./ofelia.ini - Auto-detection priority (first in list wins) - Auto-detection fallback when no config exists - Explicit --config bypasses auto-detection
Summary
This PR fixes the
doctorcommand's config file detection and improves the getting-started experience:Auto-detect config files: When
--configis not specified, doctor now searches multiple locations:./ofelia.ini(created byofelia init)./config.ini/etc/ofelia/config.ini/etc/ofelia.iniSuggest
ofelia init: When no config file is found, the error message now suggests runningofelia initand shows all searched pathsREADME documentation: Added documentation for both
initanddoctorcommandsProblem
Previously, running
ofelia initfollowed byofelia doctorwould fail because:initcreates./ofelia.iniby defaultdoctoralways checked/etc/ofelia/config.ini(hard-coded default)Test Plan
ofelia doctorwith./ofelia.inipresent → finds and validates itofelia doctorwith no config anywhere → showsofelia initsuggestionofelia doctor --config=/custom/path→ uses specified path