@iyulab/oops
Version:
Core SDK for Oops - Safe text file editing with automatic backup
48 lines • 1.19 kB
JavaScript
;
/**
* Configuration management for Oops
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigManager = exports.DEFAULT_CONFIG = void 0;
exports.DEFAULT_CONFIG = {
workspace: {
useTemp: false,
path: null,
},
safety: {
confirmKeep: true,
confirmUndo: true,
autoBackup: true,
},
diff: {
tool: 'auto',
context: 3,
},
};
class ConfigManager {
config;
constructor(config = {}) {
this.config = { ...exports.DEFAULT_CONFIG, ...config };
}
get() {
return { ...this.config };
}
set(key, value) {
const keys = key.split('.');
let current = this.config;
// Navigate to the parent object
for (let i = 0; i < keys.length - 1; i++) {
if (!(keys[i] in current)) {
current[keys[i]] = {};
}
current = current[keys[i]];
}
// Set the final value
current[keys[keys.length - 1]] = value;
}
reset() {
this.config = { ...exports.DEFAULT_CONFIG };
}
}
exports.ConfigManager = ConfigManager;
//# sourceMappingURL=config.js.map