8000 feat(sessions): loadouts, config, and debug commands by evanspearman · Pull Request #686 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn 10BC8 more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ tonic-prost = "0.14.6"
tonic-prost-build = "0.14.6"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
tracing-appender = "0.2"
thiserror = "2"
url = "2" # keep in sync with reqwest
uuid = { version = "1.23", features = ["v4", "v7", "serde"] }
Expand Down
32 changes: 32 additions & 0 deletions crates/minimal/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! Client-side config-dir resolution and `config.toml` loading.
//!
//! Both the loadouts and dirs subsystems route through this module so
//! `--config-dir`, `paths::minimal_config_dir()`, and the on-disk
//! `config.toml` layout are all resolved in one place.

use std::path::PathBuf;

use crate::GlobalArgs;

/// Resolve `<config>/minimal` on the platform's user config dir,
/// or the `--config-dir` override if the caller passed one. The
/// base for both the loadouts subdir and the client config file.
pub fn resolve_minimal_config_dir(global: &GlobalArgs) -> PathBuf {
if let Some(dir) = &global.config_dir {
return dir.join("minimal");
}
paths::minimal_config_dir()
.as_utf8_path()
.as_std_path()
.to_path_buf()
}

/// Read the client config once, so both loadout resolution and
/// compose-option handling see the same values without hitting the
/// disk twice.
pub fn read_client_config(
global: &GlobalArgs,
) -> Result<sessions::client::config::Config, anyhow::Error> {
let cfg_path = resolve_minimal_config_dir(global).join("config.toml");
sessions::client::config::read_config_or_default(&cfg_path).map_err(|e| anyhow::anyhow!("{e}"))
}
Loading
Loading
0