1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Process-wide storage for the loaded configuration.
//!
//! `init_config()` is called once at startup from `try_main()`; from
//! that point on, all read sites use `config()` to get the loaded
//! `Config` (or `None` if no config file exists).
use OnceLock;
use ConfigError;
use try_load_config;
use Config;
/// Storage for the user's configuration.
///
/// Populated once by `init_config()` early in `try_main()`, then read
/// through `config()` for the rest of the process lifetime. The
/// outer `Option` represents "no config file exists" (which is fine —
/// lx falls back to compiled defaults), while errors during loading
/// surface as `Err` from `init_config()` rather than being silently
/// swallowed.
static CONFIG_STORE: = new;
/// Load the user's configuration file.
///
/// Called once from `main` before any other config-reading code runs.
/// Errors here are fatal — the pre-0.9 graceful fallback for broken
/// configs (eprintln + continue with compiled defaults) is gone.
///
/// # Errors
///
/// Returns whatever `try_load_config()` returns: `ConfigError::Io`
/// for unreadable files, `ConfigError::Parse` for invalid TOML,
/// `ConfigError::NeedsUpgrade` for old-format files, etc.
/// Read the loaded configuration.
///
/// Returns `None` if no config file exists, or if `init_config()`
/// has not yet been called (e.g. during `--upgrade-config`, which
/// loads the file directly).