"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createKeysCommand = createKeysCommand;
const kleur_1 = require("kleur");
const ssh_manager_1 = require("../services/ssh-manager");
const env_loader_1 = require("../utils/env-loader");
const logger_1 = require("../utils/logger");
const i18n_1 = require("../i18n");
const command_1 = require("../utils/command");
function createKeysCommand() {
    const command = (0, command_1.createCommand)('keys')
        .description((0, i18n_1.t)('commands.keys.description'));
    command
        .addCommand((0, command_1.createCommand)('ls')
        .alias('list')
        .description((0, i18n_1.t)('commands.keys.ls.description'))
        .action(() => {
        try {
            const config = env_loader_1.envLoader.load();
            const keys = ssh_manager_1.sshManager.listKeys(config.SSH_VOLUME_NAME);
            if (keys.length === 0) {
                logger_1.logger.warn('No injected SSH keys found.');
                return;
            }
            keys.forEach((key) => console.log(`  ${(0, kleur_1.green)('+')} ${key}`));
        }
        catch (error) {
            const message = error instanceof Error ? error.message : String(error);
            logger_1.logger.error(`Failed to list SSH keys: ${message}`);
            process.exit(1);
        }
    }));
    command
        .addCommand((0, command_1.createCommand)('add')
        .description((0, i18n_1.t)('commands.keys.add.description'))
        .argument('<path>', (0, i18n_1.t)('arguments.keyPath'))
        .action((keyPath) => {
        try {
            const config = env_loader_1.envLoader.load();
            ssh_manager_1.sshManager.addKey(keyPath, config.SSH_VOLUME_NAME);
            logger_1.logger.success('SSH key added successfully.');
        }
        catch (error) {
            const message = error instanceof Error ? error.message : String(error);
            logger_1.logger.error(`Failed to add SSH key: ${message}`);
            process.exit(1);
        }
    }));
    return command;
}
//# sourceMappingURL=keys.js.map