refactor: CLI to load config once via global OnceLock #1405
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the suggestion to reduce calls to the CLI config loader by introducing a single, lazy, global configuration. As discussed in issue refactor: reduce calls for load_config_file in CLI link and related comments in the bech32 PR thread link, repeatedly reading miden-client.toml in various commands is unnecessary and can be error-prone. I added a get_cli_config() accessor backed by std::sync::OnceLock that loads the config exactly once from the current working directory and then returns a shared reference. All commands that previously called load_config_file() now use get_cli_config(), including startup in lib.rs, info.rs, account.rs, new_transactions.rs, and new_account.rs. I also refactored load_faucet_details_map() to use the global config instead of reloading from disk and removed the old load_config_file() helper entirely. This change reduces disk I/O, simplifies function signatures in call sites, and keeps behavior unchanged; config parsing errors still surface early and thread-safely.
fix #857