Skip to content

Commit d6cb422

Browse files
Update: Group menu and total number of operation
1 parent 94f764d commit d6cb422

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

src/cli/index.ts

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,51 @@ async function showMenu(): Promise<void> {
4242
}
4343
console.log(chalk.gray('--------------------------------------------------\n'));
4444

45-
const choices = COMMANDS_LIST.map((cmd) => ({
46-
name: `${cmd.name} ${cmd.command.includes('<') ? '(requires input)' : ''}`,
47-
value: cmd.handler, // use handler instead of direct git command
48-
short: cmd.category,
49-
}));
45+
// Count total commands and categories
46+
const totalOperations = COMMANDS_LIST.length;
47+
const categories = [...new Set(COMMANDS_LIST.map((cmd) => cmd.category))];
48+
const totalCategories = categories.length;
5049

50+
console.log(chalk.yellowBright(`\n📊 Total operations available: ${totalOperations}`));
51+
console.log(chalk.yellowBright(`📁 Categories: ${totalCategories} (${categories.join(', ')})`));
52+
53+
console.log(chalk.gray('\n--------------------------------------------------\n'));
54+
55+
// Group COMMANDS_LIST by category
56+
const grouped = COMMANDS_LIST.reduce<Record<string, typeof COMMANDS_LIST>>((acc, cmd) => {
57+
if (!acc[cmd.category]) acc[cmd.category] = [];
58+
acc[cmd.category].push(cmd);
59+
return acc;
60+
}, {});
61+
62+
const choices: any[] = [];
63+
64+
// Build grouped menu
65+
for (const [category, cmds] of Object.entries(grouped)) {
66+
choices.push(
67+
new inquirer.Separator(chalk.cyanBright.bold(`── ${category.toUpperCase()} COMMANDS ──`)),
68+
);
69+
70+
cmds.forEach((cmd) => {
71+
choices.push({
72+
name: `${cmd.name} ${cmd.command.includes('<') ? chalk.gray('(requires input)') : ''}`,
73+
value: cmd.handler,
74+
short: cmd.category,
75+
});
76+
});
77+
}
78+
79+
choices.push(new inquirer.Separator());
80+
choices.push({ name: chalk.redBright('❌ Exit'), value: 'exit' });
81+
82+
// Interactive prompt
5183
const { selected } = await inquirer.prompt([
5284
{
5385
type: 'list',
5486
name: 'selected',
5587
message: 'Select a Git operation to perform:',
5688
pageSize: 50,
57-
choices: [...choices, new inquirer.Separator(), { name: '❌ Exit', value: 'exit' }],
89+
choices,
5890
},
5991
]);
6092

0 commit comments

Comments
 (0)