Environment variable configuration options
Explanation
There are some behaviors that might be incredibly annoying for end users if they can't turn them
off: colorization, which subsystems to use, default text encoding, etc. We can reasonably
auto-detect the correct behavior in 99% of cases, but sometimes the end user does know better, and
should be able to override the autodetection even from many layers up the stack. Therefore, we
should provide a small table of environment variables that can configure Crucible's most impactful
behavior from anywhere.
Task
Create a new namespace core::environment
that provides a super simple API:
- A
constexpr
definition for each configuration variable we recognize (start with colorization,
because we can already use that one)
- A table mapping the variable names to parsed values (we'll load them once on startup and then
cache them)
- A way to iterate over the table
- A way to get a particular variable
- An initializer function that seeds the table with its default values, then reads each environment
variable and, if they're set, parses them and puts the result in the table
- It is acceptable to hard crash (not assertion failure, but terminate the program) if
initialization fails
- Call the initializer function from
boot::main::bridge_os_main_to_crucible_launch()
so it's
available in all executables
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
# Environment variable configuration options
## Explanation
There are some behaviors that might be incredibly annoying for end users if they can't turn them
off: colorization, which subsystems to use, default text encoding, etc. We can reasonably
auto-detect the correct behavior in 99% of cases, but sometimes the end user does know better, and
should be able to override the autodetection even from many layers up the stack. Therefore, we
should provide a small table of environment variables that can configure Crucible's most impactful
behavior from anywhere.
## Task
Create a new namespace `core::environment` that provides a super simple API:
- A `constexpr` definition for each configuration variable we recognize (start with colorization,
because we can already use that one)
- A table mapping the variable names to parsed values (we'll load them once on startup and then
cache them)
- A way to iterate over the table
- A way to get a particular variable
- An initializer function that seeds the table with its default values, then reads each environment
variable and, if they're set, parses them and puts the result in the table
- It is acceptable to hard crash (not assertion failure, but terminate the program) if
initialization fails
- Call the initializer function from `boot::main::bridge_os_main_to_crucible_launch()` so it's
available in all executables