@tastekim/chat-cli
Version:
๐ฌConnect with developers worldwide through an interactive terminal chat experience while you code!๐ป
174 lines โข 7.58 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupConfigCommands = setupConfigCommands;
const feature_flags_1 = require("../core/feature-flags");
const chalk_1 = __importDefault(require("chalk"));
const inquirer_1 = __importDefault(require("inquirer"));
function setupConfigCommands(program) {
const configCmd = program
.command('config')
.description('Configure Chat-CLI settings and features');
// ํ์ฌ ์ค์ ํ์
configCmd
.command('show')
.description('Show current configuration')
.action(() => {
const flagManager = feature_flags_1.FeatureFlagManager.getInstance();
flagManager.printCurrentConfig();
});
// Multi-room ๋ชจ๋ ํ์ฑํ
configCmd
.command('enable-multi-room')
.description('Enable multi-room chat features')
.action(() => {
const flagManager = feature_flags_1.FeatureFlagManager.getInstance();
flagManager.enableMultiRoom(true);
console.log(chalk_1.default.green('โ
Multi-room mode enabled!'));
console.log(chalk_1.default.gray(' This enables:'));
console.log(chalk_1.default.gray(' โข Multiple room management'));
console.log(chalk_1.default.gray(' โข Room tabs and navigation'));
console.log(chalk_1.default.gray(' โข Unread message indicators'));
console.log(chalk_1.default.gray(' โข Lobby as default room'));
console.log('');
console.log(chalk_1.default.blue('๐ก Restart chat-cli to see the changes'));
});
// Multi-room ๋ชจ๋ ๋นํ์ฑํ
configCmd
.command('disable-multi-room')
.description('Disable multi-room chat features (revert to classic mode)')
.action(() => {
const flagManager = feature_flags_1.FeatureFlagManager.getInstance();
flagManager.enableMultiRoom(false);
console.log(chalk_1.default.yellow('โ ๏ธ Multi-room mode disabled'));
console.log(chalk_1.default.gray(' Reverted to classic single-room mode'));
console.log('');
console.log(chalk_1.default.blue('๐ก Restart chat-cli to see the changes'));
});
// ํ๋ผ์ด๋น ๋ฐฉ ๊ธฐ๋ฅ ํ ๊ธ
configCmd
.command('toggle-private-rooms')
.description('Enable/disable private room features')
.action(() => {
const flagManager = feature_flags_1.FeatureFlagManager.getInstance();
const config = flagManager.getConfig();
const newState = !config.enablePrivateRooms;
flagManager.enablePrivateRooms(newState);
console.log(chalk_1.default.cyan(`๐ Private rooms ${newState ? 'enabled' : 'disabled'}`));
if (newState) {
console.log(chalk_1.default.gray(' You can now create password-protected rooms'));
}
});
// ๊ธฐ๋ณธ ๋ฐฉ ์ค์
configCmd
.command('set-default-room <room>')
.description('Set default room on startup')
.action((room) => {
const flagManager = feature_flags_1.FeatureFlagManager.getInstance();
flagManager.setDefaultRoom(room);
console.log(chalk_1.default.green(`โ
Default room set to: ${room}`));
});
// ์ธํฐ๋ํฐ๋ธ ์ค์
configCmd
.command('setup')
.description('Interactive configuration setup')
.action(async () => {
const flagManager = feature_flags_1.FeatureFlagManager.getInstance();
const currentConfig = flagManager.getConfig();
console.log(chalk_1.default.cyan('๐ ๏ธ Chat-CLI Interactive Setup'));
console.log('');
// ๋จ๊ณ๋ณ๋ก ์ง๋ฌธํ๊ธฐ (inquirer v12 ํธํ)
const enableMultiRoom = await inquirer_1.default.prompt([{
type: 'confirm',
name: 'value',
message: 'Enable multi-room chat features?',
default: currentConfig.enableMultiRoom,
}]);
const defaultRoom = await inquirer_1.default.prompt([{
type: 'list',
name: 'value',
message: 'Choose default room:',
choices: [
{ name: '๐ Lobby (Multi-room hub)', value: 'lobby' },
{ name: '๐ฐ๐ท Korean Room', value: 'korean' },
{ name: '๐บ๐ธ English Room', value: 'english' },
{ name: '๐ช๐ธ Spanish Room', value: 'spanish' }
],
default: currentConfig.defaultRoom
}]);
let enablePrivateRooms = { value: false };
let maxJoinedRooms = { value: 5 };
if (enableMultiRoom.value) {
enablePrivateRooms = await inquirer_1.default.prompt([{
type: 'confirm',
name: 'value',
message: 'Enable private room creation?',
default: currentConfig.enablePrivateRooms,
}]);
maxJoinedRooms = await inquirer_1.default.prompt([{
type: 'number',
name: 'value',
message: 'Maximum number of rooms you can join simultaneously:',
default: currentConfig.maxJoinedRooms,
validate: (input) => {
if (input < 1 || input > 10) {
return 'Please enter a number between 1 and 10';
}
return true;
},
}]);
}
const answers = {
enableMultiRoom: enableMultiRoom.value,
enablePrivateRooms: enablePrivateRooms.value,
defaultRoom: defaultRoom.value,
maxJoinedRooms: maxJoinedRooms.value
};
// ์ค์ ์ ์ฉ
if (answers.enableMultiRoom) {
flagManager.enableMultiRoom(true);
if (answers.enablePrivateRooms !== undefined) {
flagManager.enablePrivateRooms(answers.enablePrivateRooms);
}
if (answers.maxJoinedRooms) {
flagManager.setMaxJoinedRooms(answers.maxJoinedRooms);
}
}
else {
flagManager.enableMultiRoom(false);
}
flagManager.setDefaultRoom(answers.defaultRoom);
console.log('');
console.log(chalk_1.default.green('โ
Configuration saved successfully!'));
console.log('');
flagManager.printCurrentConfig();
console.log(chalk_1.default.blue('๐ก Restart chat-cli to apply the changes'));
});
// ์ค์ ์ด๊ธฐํ
configCmd
.command('reset')
.description('Reset all settings to defaults')
.action(async () => {
const { confirm } = await inquirer_1.default.prompt([
{
type: 'confirm',
name: 'confirm',
message: 'Are you sure you want to reset all settings to defaults?',
default: false
}
]);
if (confirm) {
const flagManager = feature_flags_1.FeatureFlagManager.getInstance();
flagManager.resetToDefaults();
console.log(chalk_1.default.yellow('โ ๏ธ All settings have been reset to defaults'));
console.log('');
flagManager.printCurrentConfig();
}
else {
console.log(chalk_1.default.gray('Reset cancelled'));
}
});
}
//# sourceMappingURL=config.js.map