Skip to content

Commit 947d91f

Browse files
committed
feat(settings): add UpdateConfig for startup update check configuration
1 parent 7b3da73 commit 947d91f

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

shello_cli/settings/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class CommandTrustConfig:
8787
denylist: List[str] = field(default_factory=list)
8888

8989

90+
@dataclass
91+
class UpdateConfig:
92+
"""Configuration for update checking."""
93+
94+
check_on_startup: bool = True
95+
96+
9097
@dataclass
9198
class UserSettings:
9299
"""User-level settings stored in ~/.shello_cli/user-settings.yml."""
@@ -98,6 +105,7 @@ class UserSettings:
98105
vertex_config: Optional[ProviderConfig] = None
99106
output_management: Optional[OutputManagementConfig] = None
100107
command_trust: Optional[CommandTrustConfig] = None
108+
update_config: Optional[UpdateConfig] = field(default_factory=UpdateConfig)
101109

102110

103111
@dataclass

shello_cli/settings/serializers.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
from typing import Any, Dict, Optional
9-
from .models import UserSettings, ProviderConfig, OutputManagementConfig, CommandTrustConfig
9+
from .models import UserSettings, ProviderConfig, OutputManagementConfig, CommandTrustConfig, UpdateConfig
1010

1111

1212
def generate_yaml_with_comments(settings: UserSettings) -> str:
@@ -179,6 +179,25 @@ def generate_yaml_with_comments(settings: UserSettings) -> str:
179179
"# # denylist:",
180180
"# # - my-dangerous-command",
181181
])
182+
lines.append("")
183+
184+
# Update Configuration Section
185+
lines.extend([
186+
"# =============================================================================",
187+
"# UPDATE CONFIGURATION (optional - uses defaults if not specified)",
188+
"# =============================================================================",
189+
"# Controls automatic update checking behavior.",
190+
"# Uncomment and modify to customize:",
191+
"#",
192+
])
193+
194+
if settings.update_config:
195+
lines.extend(_serialize_update_config(settings.update_config))
196+
else:
197+
lines.extend([
198+
"# update_config:",
199+
"# check_on_startup: true # Check for updates when Shello CLI starts",
200+
])
182201

183202
return "\n".join(lines)
184203

@@ -277,3 +296,11 @@ def _serialize_command_trust(config: CommandTrustConfig) -> list:
277296
lines.append(f" - {pattern}")
278297

279298
return lines
299+
300+
301+
def _serialize_update_config(config: UpdateConfig) -> list:
302+
"""Serialize UpdateConfig to YAML lines."""
303+
lines = ["update_config:"]
304+
lines.append(f" check_on_startup: {str(config.check_on_startup).lower()}")
305+
306+
return lines

0 commit comments

Comments
 (0)