"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const chalk_1 = __importDefault(require("chalk"));
const open_1 = __importDefault(require("open"));
const base_1 = __importDefault(require("./base"));
class Open extends base_1.default {
    async openDetail(projectPath, force) {
        let openCommand = 'opdev://';
        if (projectPath) {
            const openPath = path_1.default.isAbsolute(projectPath)
                ? projectPath
                : path_1.default.join(process.cwd(), projectPath);
            console.log(chalk_1.default.green('open projectPath:', openPath));
            openCommand += `gadget/open?path=${encodeURIComponent(openPath)}`;
            if (force) {
                openCommand += '&force';
            }
        }
        else {
            console.log(chalk_1.default.green('open opdev'));
        }
        try {
            await (0, open_1.default)(openCommand);
            console.log('open opdev success');
        }
        catch (e) {
            console.log(chalk_1.default.red('open opdev failed:', e));
        }
    }
}
exports.default = Open;
