diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-02 21:48:02 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-02 21:48:02 +0300 |
| commit | b751d102f158968aab681cb663d27b4c32197f62 (patch) | |
| tree | 85d03609314559df7705c2cb0ab4e37ab6d9715f /src/config | |
| parent | 295b09ca25edbccac65401ee84fa420dd3888aad (diff) | |
feat: add preview update channel
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/io.rs | 16 | ||||
| -rw-r--r-- | src/config/model.rs | 46 |
2 files changed, 62 insertions, 0 deletions
diff --git a/src/config/io.rs b/src/config/io.rs index 2c6d78ab..1ea928a3 100644 --- a/src/config/io.rs +++ b/src/config/io.rs @@ -183,6 +183,14 @@ fn load_live_config_from_str(content: &str) -> Result<LoadedConfig, Vec<String>> ); load_live_section( table, + "update", + "update config", + &mut diagnostics, + &mut invalid_sections, + |section| config.update = section, + ); + load_live_section( + table, "ui", "ui config", &mut diagnostics, @@ -213,6 +221,14 @@ fn load_live_config_from_str(content: &str) -> Result<LoadedConfig, Vec<String>> &mut invalid_sections, |section| config.experimental = section, ); + load_live_section( + table, + "remote", + "remote config", + &mut diagnostics, + &mut invalid_sections, + |section| config.remote = section, + ); Ok(LoadedConfig { config, diff --git a/src/config/model.rs b/src/config/model.rs index f815fb8d..7895341f 100644 --- a/src/config/model.rs +++ b/src/config/model.rs @@ -10,6 +10,37 @@ use super::{ #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)] #[serde(rename_all = "lowercase")] +pub enum UpdateChannelConfig { + #[default] + Stable, + Preview, +} + +impl UpdateChannelConfig { + pub fn as_str(self) -> &'static str { + match self { + Self::Stable => "stable", + Self::Preview => "preview", + } + } +} + +#[derive(Debug, Clone, Copy, Deserialize)] +#[serde(default)] +pub struct UpdateConfig { + pub channel: UpdateChannelConfig, +} + +impl Default for UpdateConfig { + fn default() -> Self { + Self { + channel: UpdateChannelConfig::Stable, + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)] +#[serde(rename_all = "lowercase")] pub enum ToastDelivery { #[default] Off, @@ -187,6 +218,7 @@ pub struct Config { pub theme: ThemeConfig, pub terminal: TerminalConfig, pub session: SessionConfig, + pub update: UpdateConfig, pub keys: KeysConfig, pub ui: UiConfig, pub worktrees: WorktreesConfig, @@ -589,6 +621,20 @@ mod tests { use super::*; #[test] + fn update_channel_defaults_stable_and_parses() { + let default_config = Config::default(); + assert_eq!(default_config.update.channel, UpdateChannelConfig::Stable); + + let toml = r#" +[update] +channel = "preview" +"#; + let config: Config = toml::from_str(toml).unwrap(); + assert_eq!(config.update.channel, UpdateChannelConfig::Preview); + assert_eq!(config.update.channel.as_str(), "preview"); + } + + #[test] fn terminal_default_shell_defaults_empty_and_parses() { let default_config = Config::default(); assert!(default_config.terminal.default_shell.is_empty()); |
