Add --config CLI flag to specify custom configuration file path#3
Conversation
This enhancement allows users to specify multiple document directories
and glob patterns in config.json, providing more flexibility in
organizing and indexing markdown files.
Features:
- Config: Changed from single 'documents_dir' to 'document_patterns' array
- Supports both directory paths and glob patterns (e.g., "./docs/**/*.md")
- Backwards compatible: old 'documents_dir' automatically migrated
- Sync: Uses pattern matching to find files instead of single directory walk
- MCP tools: Updated path validation to work with multiple base directories
- Tests: Added comprehensive tests for pattern expansion and migration
- Documentation: Updated README with examples and pattern syntax
Example config.json:
{
"document_patterns": [
"./documents",
"./notes/**/*.md",
"./projects/backend/**/*.md"
],
...
}
Pattern examples:
- "./documents" - All .md files in directory
- "./docs/**/*.md" - Recursive search with **
- "./projects/*/docs/*.md" - Wildcard patterns
- "/path/to/external/docs" - Absolute paths
Changes: - Add flag parsing in cmd/main.go to accept --config parameter - Modify config.Load() to accept configPath parameter (defaults to "config.json") - Add comprehensive tests for custom config path functionality - Update README.md with documentation for --config flag (English and Japanese) Benefits: - Support running multiple instances with different configurations - Enable testing different models or chunk sizes easily - Allow separate dev/test/prod configurations - Follow industry standard CLI patterns (docker, kubectl, git, etc.) Tests added: - TestLoadConfig_CustomPath: Verify custom config loading - TestLoadConfig_CustomPath_NotFound: Test fallback to defaults - TestLoadConfig_CustomPath_InvalidJSON: Test graceful degradation - TestLoadConfig_RelativeAndAbsolutePaths: Test both path types
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
…1BK5KtdbNwCE1 Add support for multiple document paths with glob patterns
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
|
Thanks for this contribution! The There are some merge conflicts with the current main branch, but I'll resolve them on my end after merging. No action needed from you. Merging now - thank you! 🎉 |
- Fix undefined variable: configFile -> configPath in config.go - Fix truncated test: restore complete TestLoadConfig_CustomPath - Remove unused import: path/filepath from sync.go - Update integration tests: DocumentsDir -> DocumentPatterns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix merge issues from PR #3 (--config CLI flag)
|
I've resolved the merge conflicts and merged the fix in PR #6. Everything is working now! Thank you again for your contribution - this feature is a great addition to DevRag. 🙏 |
User description
Changes:
Benefits:
Tests added:
PR Type
Enhancement, Tests
Description
Add
--configCLI flag to specify custom configuration file pathModify
config.Load()to accept configPath parameter with defaultsAdd four comprehensive tests for custom config path functionality
Update README.md with CLI flag documentation (English and Japanese)
Diagram Walkthrough
File Walkthrough
main.go
Add CLI flag parsing for config pathcmd/main.go
flagpackage for CLI argument parsing--configparameter with default valueconfig.jsonconfig.Load()functionconfig.go
Support dynamic config file path parameterinternal/config/config.go
Load()function signature to acceptconfigPathstring parameterconfig.jsonif not providedconfigPathinstead ofhardcoded constant
config.jsonpathconfig_test.go
Add comprehensive custom config path testsinternal/config/config_test.go
""toLoad()for defaultbehavior
TestLoadConfig_CustomPath()to verify custom config file loadingwith various settings
TestLoadConfig_CustomPath_NotFound()to test fallback to defaultswhen file missing
TestLoadConfig_CustomPath_InvalidJSON()to test gracefuldegradation with invalid JSON
TestLoadConfig_RelativeAndAbsolutePaths()to verify both relativeand absolute path support
README.md
Document --config flag in English and JapaneseREADME.md
--configcommand-line optionwith usage example
testing, dev/test/prod separation)
--configflag usageequivalent examples and use cases
--configflag