For #251, I want to use the `Language<'_>` type inside `Config`. The languages will either refer to values read from the config file, or to static strings from `get_languages_from_env`, so just using `Language<'static>` is not an option.
Instead, some input for the `Config` needs to be persisted in the main function for the duration of the program so that the config can reference it. At first I was hoping that this input would be the `contents` string from `RawConfig::load`, but as it turns out you cannot (in general) deserialize strings from toml without having to alter them, for example when they contain escapes like `\n`. Thus, the toml parser seemingly doesn't even try and just throws an error when deserializing into a borrowed string (even if it could in theory just return the correct substring from the input). Given that `RawConfig` should stay static then, the raw config itself is the next best thing to keep alive and have the config reference into.
While this change might seem a bit drastic for little benefit, I am actually pretty happy with it because I want to unify the configuration anyways at some point so that the CLI arguments, environment variables, and the config file are merged at the beginning of the program and then only a single config is used for the everything (no more `enable_styles` everywhere!). At this time, the `Config` would have references into `Cli` anyways, and having the `ConfigLoader` as an entity for this merging also seems natural.
* Remove unneeded Clone bound on Dedup
* Introduce Language struct to represent language strings
* Move language directory name logic into own method on Language type
Currently, `main` uses `print_error` and `process::exit` in several
places. These could be unified by propagating errors via `Result`s.
There is one place left that manually calls `print_error`, because the
error should be followed by help instructions printed without any
highlighting.
Otherwise the builds made by `TestEnv::command` will conflict with each
other. This manifested itself on Windows with
> linking with `link.exe` failed: exit code: 1104
> LINK : fatal error LNK1104: cannot open file '...'
Since these tests require internet access, they are undesirable in
reproducible builds [1] (and in general, I guess). The overall goal is
to shrink this list to a minimum. At some point we might remove the
feature again and ignore online tests by default. Before putting much
thought into refactoring the remaining tests, we should wait until we
have introduced the `updates.archive_url` option. Then, we could run a
local webserver that serves a known file. Until then, having the feature
already helps discourage using `--update` in tests that don't need it
and allows for quicker test execution locally if wanted.
- [1]: edf04b75c1/pkgs/by-name/te/tealdeer/package.nix (L34-L44)
- Adapt to `thing.paint(style)` API; was `style.paint(thing)`
- Remove `yansi::Paint::enable_windows_ascii()` in style usage decision;
removed in yansi commit b186eb5bfb, which introduced "automatic"
support for Windows: "If support is not available, styling is disabled
and no styling sequences are emitted", fitting the `Auto` option
- Respect `--color=always` even if we know it won't work
---------
Co-authored-by: Niklas Mohrin <dev@niklasmohrin.de>