#pragma once #include #include #include #include /// The CLI's own, global state: where it lives and what the user configured. namespace breeze { /// $BREEZE_HOME, or ~/.breeze. Holds config.json, the installed CLI versions (cli/), the SDK /// snapshots (sdk/) and cached indexes. std::filesystem::path breezeHome(); /// The keys of config.json. Each can also come from the environment (BREEZE_EDITOR, /// BREEZE_SDK_SOURCE, BREEZE_CLI_SOURCE), which wins. namespace config { inline constexpr const char* Editor = "editor"; inline constexpr const char* SdkSource = "sdkSource"; inline constexpr const char* CliSource = "cliSource"; } class GlobalConfig { public: /// Reads config.json (an absent file is an empty configuration). static GlobalConfig load(); /// The environment's value for the key if set, else the file's. [[nodiscard]] std::optional effective(const std::string& key) const; /// The file's value only. [[nodiscard]] std::optional stored(const std::string& key) const; void set(const std::string& key, const std::string& value); void erase(const std::string& key); void save() const; private: nlohmann::json m_data = nlohmann::json::object(); }; }