import { createDefaultIntegrationRegistry } from '../index.js';
import { ConsoleLogger, DiscoveryEngine } from '../core/index.js';
import { commandDiscover } from './commands.discover.js';
import { commandInspect } from './commands.inspect.js';
import { commandList } from './commands.list.js';
import { commandSetup } from './commands.setup.js';

export class CliRuntime {
  public integrationRegistry = createDefaultIntegrationRegistry();
  public discoveryEngine = new DiscoveryEngine(this.integrationRegistry);
  public logger = new ConsoleLogger();

  public async list(): Promise<string> {
    return commandList(this.integrationRegistry);
  }

  public async inspect(domainArg: string): Promise<string> {
    return commandInspect(this.integrationRegistry, domainArg);
  }

  public async discover() {
    return commandDiscover(this.discoveryEngine, {
      logger: this.logger,
    });
  }

  public async setup(domainArg: string) {
    return commandSetup(this.integrationRegistry, domainArg);
  }
}
