feat: setSilent() + opciones válidas en comentarios config
- setSilent(): Establece valor sin disparar observers Útil para carga masiva desde BD (evita writes innecesarios) - save(): Muestra opciones válidas en comentarios Ejemplo: # Modo validación NIF [Estricto,Permisivo,Desactivado] 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2abb85d172
commit
3dd835eb51
1 changed files with 16 additions and 2 deletions
|
|
@ -563,13 +563,20 @@ pub fn save(
|
||||||
const value_len = value.len;
|
const value_len = value.len;
|
||||||
const total_len = key_len + 2 + value_len;
|
const total_len = key_len + 2 + value_len;
|
||||||
|
|
||||||
if (total_len < 40 and v.description.len > 0) {
|
// Construir comentario con opciones válidas si existen
|
||||||
|
var comment_buf: [256]u8 = undefined;
|
||||||
|
const comment: []const u8 = if (v.auto_validate) |valid|
|
||||||
|
std.fmt.bufPrint(&comment_buf, "{s} [{s}]", .{ v.description, valid }) catch v.description
|
||||||
|
else
|
||||||
|
v.description;
|
||||||
|
|
||||||
|
if (total_len < 40 and comment.len > 0) {
|
||||||
const padding = 40 - total_len;
|
const padding = 40 - total_len;
|
||||||
const line = std.fmt.bufPrint(&line_buf, "{s}: {s}{s}# {s}\n", .{
|
const line = std.fmt.bufPrint(&line_buf, "{s}: {s}{s}# {s}\n", .{
|
||||||
v.config_key,
|
v.config_key,
|
||||||
value,
|
value,
|
||||||
spaces(padding),
|
spaces(padding),
|
||||||
v.description,
|
comment,
|
||||||
}) catch unreachable; // Buffer 1024 es suficiente
|
}) catch unreachable; // Buffer 1024 es suficiente
|
||||||
try file.writeAll(line);
|
try file.writeAll(line);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -760,6 +767,13 @@ pub fn ConfigManager(
|
||||||
self.notifyObservers(change);
|
self.notifyObservers(change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Establece un valor SIN notificar observers
|
||||||
|
/// Útil para carga masiva desde BD (evita writes innecesarios)
|
||||||
|
pub fn setSilent(self: *Self, key: []const u8, value: []const u8) ConfigError!void {
|
||||||
|
try EngineType.set(&self.config, key, value);
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// Busca variable por config_key
|
/// Busca variable por config_key
|
||||||
fn findVariableByKey(key: []const u8) ?*const ConfigVariable {
|
fn findVariableByKey(key: []const u8) ?*const ConfigVariable {
|
||||||
inline for (variables) |*v| {
|
inline for (variables) |*v| {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue