"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createApiCommandHandler = void 0;
const named_command_router_1 = require("../named-command-router");
function createApiCommandRoutes(dependencies) {
    return [
        { name: 'create', handle: dependencies.create },
        { name: 'list', handle: dependencies.list },
        { name: 'discover', handle: dependencies.discover },
        { name: 'copy', handle: dependencies.copy },
        { name: 'export', handle: dependencies.export },
        { name: 'import', handle: dependencies.import },
        { name: 'remove', aliases: ['delete', 'rm'], handle: dependencies.remove },
    ];
}
/**
 * Factory for building an api-command handler with injectable dependencies.
 * Extracted from index.ts so tests can import without loading all subcommand modules.
 */
function createApiCommandHandler(dependencies) {
    const routes = createApiCommandRoutes(dependencies);
    return async (args) => {
        await (0, named_command_router_1.dispatchNamedCommand)({
            args,
            routes,
            onHelp: dependencies.help,
            onUnknown: dependencies.unknown,
            allowEmptyHelp: true,
        });
    };
}
exports.createApiCommandHandler = createApiCommandHandler;
//# sourceMappingURL=handler.js.map