Allow specifying custom config dir when launching via CLI#16
Merged
Conversation
Add --config-dir option to allow using arbitrary config directories instead of always using ~/.moneyflow. Changes: - Added --config-dir option to main CLI group - Pass config_dir through launch_monarch_mode() to MoneyflowApp - MoneyflowApp stores config_dir and passes to managers - Convert string to Path for CredentialManager (requires Path type) - DataManager receives string config_dir (already accepts Optional[str]) - Added logging when custom config_dir is used - Auto-creates directory if it doesn't exist (via CredentialManager) Usage: moneyflow --config-dir /tmp/test-config moneyflow --config-dir ~/configs/moneyflow-test --demo Use cases: - Testing with isolated configs - Running multiple instances with different configurations - Development and debugging - CI/CD with temporary config directories Default behavior unchanged: config_dir=None uses ~/.moneyflow All 895 tests pass ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Previously, --config-dir was only partially implemented and would still write to the default ~/.moneyflow directory, overwriting credentials and logs. Fixed the following issues: 1. Logging always wrote to ~/.moneyflow/moneyflow.log - Updated setup_logging() to accept config_dir parameter - Pass config_dir through all launch functions 2. Cache path was hardcoded to ~/.moneyflow/cache - Updated cli.py to respect config_dir when constructing cache path 3. Credential screens created CredentialManager without config_dir - CredentialSetupScreen now passes app.config_dir - CredentialUnlockScreen now passes app.config_dir - This was causing credentials to be overwritten in default location 4. Merchant cache fell back to ~/.moneyflow - Updated data_manager.py to use self.config_dir when available All tests pass and type checking is clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Error messages were hardcoding ~/.moneyflow/moneyflow.log even when using --config-dir. Now they construct the correct log path based on self.config_dir. Fixed in two locations: - Login error handler (line 456) - Data fetch error handler (line 624) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
When loading an account with 0 transactions, the DataFrame has no rows and no columns. Attempting to filter by the "date" column would crash with: ColumnNotFoundError: unable to find column "date" Fixed by adding an early return in get_filtered_df() when the DataFrame is empty (len(df) == 0), avoiding all filtering operations. Fixes: state.py:560 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I set up a YNAB account for testing and needed to be able to create an isolated config.