"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
 * penguins-eggs
 * command: yolk.ts
 * author: Piero Proietti
 * email: piero.proietti@gmail.com
 * license: MIT
 */
const core_1 = require("@oclif/core");
const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
const utils_1 = tslib_1.__importDefault(require("../../classes/utils"));
const yolk_1 = tslib_1.__importDefault(require("../../classes/yolk"));
/**
 *
 */
class ToolsYolk extends core_1.Command {
    /**
     *
     */
    async run() {
        utils_1.default.titles(this.id + ' ' + this.argv);
        const { flags } = await this.parse(ToolsYolk);
        let verbose = false;
        if (flags.verbose) {
            verbose = true;
        }
        if (utils_1.default.isRoot()) {
            if (node_fs_1.default.existsSync(ToolsYolk.dir)) {
                shelljs_1.default.exec(`rm ${ToolsYolk.dir} -rf `);
            }
            const yolk = new yolk_1.default();
            await yolk.create(verbose);
        }
        else {
            utils_1.default.useRoot(this.id);
        }
    }
}
ToolsYolk.flags = {
    help: core_1.Flags.help({ char: 'h' }),
    verbose: core_1.Flags.boolean({ char: 'v' }),
};
ToolsYolk.description = 'configure eggs to install without internet';
ToolsYolk.examples = [
    'sudo eggs tools yolk',
];
ToolsYolk.dir = '/var/local/yolk';
exports.default = ToolsYolk;
