Add config getters for logging, history and behavior settings

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
This commit is contained in:
Debian
2026-09-13 14:00:16 +02:00
co-authored by Sisyphus
parent 5b90d66276
commit 271637ee71
+30 -3
View File
@@ -72,6 +72,18 @@ class ConfigLoader:
return value.lower() in ('true', 'yes', '1', 'on')
def get_float(self, section, key, fallback=0.0):
"""Get a float configuration value"""
value = self.get(section, key)
if value is None:
return fallback
try:
return float(value)
except ValueError:
logger.warning(f'Invalid float value for [{section}] {key}: {value}')
return fallback
def get_host(self):
"""Get connection host"""
return self.get('connection', 'host')
@@ -129,8 +141,11 @@ class ConfigLoader:
return password
def get_log_level(self):
"""Get logging level"""
level_str = self.get('logging', 'level', 'INFO')
"""Get logging level (None if not configured or invalid)"""
level_str = self.get('logging', 'level')
if not level_str:
return None
levels = {
'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
@@ -138,7 +153,19 @@ class ConfigLoader:
'ERROR': logging.ERROR,
'CRITICAL': logging.CRITICAL
}
return levels.get(level_str.upper(), logging.INFO)
return levels.get(level_str.upper())
def get_max_history(self, default):
"""Get command history length from [ui] section"""
return self.get_int('ui', 'max_history', default)
def get_quit_timeout(self, default):
"""Get quit confirmation timeout from [behavior] section"""
return self.get_float('behavior', 'quit_timeout', default)
def get_respawn_delay(self, default):
"""Get respawn delay from [behavior] section"""
return self.get_float('behavior', 'respawn_delay', default)
def create_example_config():