Skip to content

Allow specifying custom config dir when launching via CLI#16

Merged
wesm merged 4 commits intomainfrom
specify-config-dir
Oct 30, 2025
Merged

Allow specifying custom config dir when launching via CLI#16
wesm merged 4 commits intomainfrom
specify-config-dir

Conversation

@wesm
Copy link
Owner

@wesm wesm commented Oct 30, 2025

I set up a YNAB account for testing and needed to be able to create an isolated config.

wesm and others added 4 commits October 29, 2025 19:01
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>
@wesm wesm merged commit 0072fd6 into main Oct 30, 2025
6 checks passed
@wesm wesm deleted the specify-config-dir branch October 30, 2025 01:15
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