Skip to main content

Module paths

Module paths 

Source
Expand description

The user’s directories, resolved in one place (sandboxed in tests). Where scope keeps the user’s files: one folder, $SCOPE_BCA_HOME, else ~/.scope-bca.

<home>/config.yaml   venues/   data/ (address book, tokens)
       state/ (session, history, tui-events, migration log, daemon files)

This module is the only place that knows the layout. Code calls these functions instead of dirs::* (clippy’s disallowed-methods enforces this).

In test builds (cfg(test) or the test-support feature, which every test crate turns on) every path is under a sandbox for each process, never the real home, and SCOPE_BCA_HOME is ignored. Tests that wrote the real folders replaced a user’s API keys, address book and token aliases with test data (#98).

Modules§

migration
Copy the user’s files from the old locations into the scope home, once.

Constants§

HOME_DIR_NAME
The scope folder’s name in the user’s home.
HOME_VAR
The environment variable that moves the whole scope folder.
TEST_HOME_VAR
In test builds, the environment variable that moves the sandbox, for a test that needs a home it controls (for example one that cannot be written).

Functions§

config_file
<home>/config.yaml.
data_dir
<home>/data: what scope keeps for the user.
home
The scope folder: $SCOPE_BCA_HOME, else ~/.scope-bca.
home_from
The root for an override and a user home. An empty override is no override; with no user home the folder is relative.
state_dir
<home>/state: session, history and logs; safe to delete.
user_home
The user’s home folder (for ~ in paths the user types).
venues_dir
<home>/venues: the user’s venue descriptors.
watchlists_dir
<home>/watchlists: the user’s saved watchlists (#47).