import { SshConfig } from './classes.sshconfig.js'; import { SshConfigWriter } from './classes.sshconfigwriter.js'; import type { IHostDefinition, IHostUpdatePreview, IHostWriteResult, ISshConfigHost, ISshConfigOptions, } from './types.js'; export class HostManager { private sshConfig: SshConfig; private sshConfigWriter: SshConfigWriter; constructor(options: ISshConfigOptions = {}) { this.sshConfig = new SshConfig(options); this.sshConfigWriter = new SshConfigWriter(options); } public async listHosts(): Promise { const result = await this.sshConfig.read(); return this.sshConfig.getDisplayHosts(result); } public async getHost(alias: string): Promise { return this.sshConfig.getHost(alias); } public async addHost(hostDefinition: IHostDefinition): Promise { return this.sshConfigWriter.addOrReplaceManagedHost(hostDefinition); } public async previewEditHost( alias: string, changes: Partial ): Promise { return this.sshConfigWriter.previewUpdateHost(alias, changes); } public async editHost(alias: string, changes: Partial): Promise { return this.sshConfigWriter.updateHost(alias, changes); } }