import assert from "node:assert" ; import { ReadonlyDeep , } from "type-fest" ; import Output from "./output.js" ; import { CommandHandlerArgumentNames , CommandName , Commands , } from "./types/command.js" ; export default class CommandHandlers { constructor ( private readonly output , private readonly commands ) { assert . strictEqual ( arguments . length , 2 ) ; assert ( typeof this . output === "object" ) ; assert ( typeof this . commands === "object" ) ; } async has ( commandName ) { assert . strictEqual ( arguments . length , 1 ) ; assert ( typeof commandName === "string" ) ; const command = this . commands [ commandName ] ; return Boolean ( command ) ; } async execute ( commandName , ... args ) { assert ( typeof commandName === "string" ) ; assert ( Array . isArray ( args ) ) ; const command = this . commands [ commandName ] ; assert ( typeof command === "object" ) ; const output = await command . execute ( ... args ) ; return output ; } async getArguments ( commandName ) { assert . strictEqual ( arguments . length , 1 ) ; assert ( typeof commandName === "string" ) ; const command = this . commands [ commandName ] ; assert ( typeof command === "object" ) ; return command . getArguments ( ) ; } }