Skip to content

Add data_dir config option for custom PrismLauncher directory#2

Merged
OneNoted merged 4 commits intomainfrom
feat/config-data-dir
Feb 19, 2026
Merged

Add data_dir config option for custom PrismLauncher directory#2
OneNoted merged 4 commits intomainfrom
feat/config-data-dir

Conversation

@OneNoted
Copy link
Owner

@OneNoted OneNoted commented Feb 19, 2026

Summary

  • Add data_dir option to ~/.config/prism-tui/config.toml for users with non-standard PrismLauncher installations (portable installs, custom paths)
  • Support tilde expansion (~/, ~\) on all platforms
  • Error explicitly when a user-configured path (env var or config) doesn't exist instead of silently falling through

Changes

  • src/data/app_config.rs — Added data_dir: Option<String> field, resolved_data_dir() method, and expand_tilde() helper
  • src/data/config.rsfind_prism_data_dir() now accepts a config override with priority: env var > config file > platform default > Flatpak. Both env var and config error explicitly on missing paths
  • src/main.rs — Load AppConfig before data dir detection and pass it through
  • src/app.rsApp::new() accepts AppConfig parameter instead of loading it internally
  • README.md — Document config file location, data_dir option, and data directory detection order

Example Config

default_sort = "Last Played"
sort_ascending = true
data_dir = "~/Games/PrismLauncher"

Test plan

  • cargo build — no warnings
  • Run without data_dir set — existing auto-detection works unchanged
  • Add data_dir = "/some/valid/path" to config — app uses that path
  • Add data_dir = "/nonexistent" — app shows config error
  • Set both env var and config data_dir — env var wins
  • Set env var to nonexistent path — app shows error instead of falling through

Greptile Summary

Added configurable data_dir option to support non-standard PrismLauncher installations (portable installs, custom paths). The implementation follows a clear priority chain: environment variable > config file > platform default > Flatpak location.

Key improvements:

  • Tilde expansion (~/, ~\) works cross-platform via expand_tilde() helper in src/data/app_config.rs:86
  • Explicit error messages when user-configured paths don't exist instead of silent fallthrough
  • Config loaded early in main.rs to pass resolved path through initialization chain
  • App::new() signature changed to accept AppConfig parameter for cleaner dependency flow
  • Documentation clearly explains config file location and data directory detection order

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • Well-structured implementation with clear separation of concerns, proper error handling for edge cases, and comprehensive documentation. The tilde expansion logic correctly handles both Unix and Windows path formats, and the priority chain is well-defined.
  • No files require special attention

Important Files Changed

Filename Overview
src/data/app_config.rs Added data_dir field with tilde expansion via expand_tilde() helper and resolved_data_dir() method
src/data/config.rs Modified find_prism_data_dir() to accept config override with explicit error handling for missing paths
src/main.rs Loads AppConfig before data dir detection and passes resolved path to find_prism_data_dir()
src/app.rs Updated App::new() to accept AppConfig parameter instead of loading internally
README.md Documented config file location, data_dir option, and data directory detection priority order

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Start: main.rs] --> B[Load AppConfig]
    B --> C[Call resolved_data_dir]
    C --> D[expand_tilde on data_dir if set]
    D --> E[find_prism_data_dir]
    
    E --> F{PRISMLAUNCHER_DATA<br/>env var set?}
    F -->|Yes| G{Path exists?}
    G -->|Yes| H[Return env var path]
    G -->|No| I[Error: env var<br/>path not found]
    
    F -->|No| J{Config data_dir<br/>provided?}
    J -->|Yes| K{Path exists?}
    K -->|Yes| L[Return config path]
    K -->|No| M[Error: config<br/>path not found]
    
    J -->|No| N{Standard platform<br/>path exists?}
    N -->|Yes| O[Return standard path]
    N -->|No| P{Flatpak path<br/>exists? Linux only}
    P -->|Yes| Q[Return Flatpak path]
    P -->|No| R[Error: DataDirNotFound]
    
    H --> S[Initialize App]
    L --> S
    O --> S
    Q --> S
Loading

Last reviewed commit: 73b75fe

@OneNoted OneNoted force-pushed the feat/config-data-dir branch from 16cf1d8 to 73b75fe Compare February 19, 2026 19:45
@OneNoted OneNoted merged commit caa5a18 into main Feb 19, 2026
12 checks passed
@OneNoted OneNoted deleted the feat/config-data-dir branch February 19, 2026 19:45
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