summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/slashCommandProcessor.ts
diff options
context:
space:
mode:
authorSeth Troisi <[email protected]>2025-05-05 21:16:13 +0000
committerSeth Troisi <[email protected]>2025-05-05 22:33:22 +0000
commit2cd976987e0a4837301df161479e44dfcca6e206 (patch)
treea4b7f0cafbd7e2f402bd2449437ccdaebdd35bd9 /packages/cli/src/ui/hooks/slashCommandProcessor.ts
parentbb52149a06012ddb5e5535d60decf40aa11ac344 (diff)
slash command altnames and support for ?
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.ts')
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.ts31
1 files changed, 9 insertions, 22 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
index 33b59b68..b4401eef 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
@@ -11,6 +11,7 @@ import { getCommandFromQuery } from '../utils/commandUtils.js';
export interface SlashCommand {
name: string; // slash command
+ altName?: string; // alternative name for the command
description: string; // flavor text in UI
action: (value: PartListUnion) => void;
}
@@ -37,6 +38,7 @@ export const useSlashCommandProcessor = (
const slashCommands: SlashCommand[] = [
{
name: 'help',
+ altName: '?',
description: 'for help on gemini-code',
action: (_value: PartListUnion) => {
setDebugMessage('Opening help.');
@@ -61,31 +63,12 @@ export const useSlashCommandProcessor = (
},
},
{
- name: 'exit',
- description: '',
- action: (_value: PartListUnion) => {
- setDebugMessage('Exiting. Good-bye.');
- const timestamp = getNextMessageId(Date.now());
- addHistoryItem(
- setHistory,
- { type: 'info', text: 'good-bye!' },
- timestamp,
- );
- process.exit(0);
- },
- },
- {
- // TODO: dedup with exit by adding altName or cmdRegex.
name: 'quit',
+ altName: 'exit',
description: '',
action: (_value: PartListUnion) => {
setDebugMessage('Quitting. Good-bye.');
const timestamp = getNextMessageId(Date.now());
- addHistoryItem(
- setHistory,
- { type: 'info', text: 'good-bye!' },
- timestamp,
- );
process.exit(0);
},
},
@@ -102,12 +85,16 @@ export const useSlashCommandProcessor = (
const [symbol, test] = getCommandFromQuery(trimmed);
// Skip non slash commands
- if (symbol !== '/') {
+ if (symbol !== '/' && symbol !== '?') {
return false;
}
for (const cmd of slashCommands) {
- if (test === cmd.name) {
+ if (
+ test === cmd.name ||
+ test === cmd.altName ||
+ symbol === cmd.altName
+ ) {
// Add user message *before* execution
const userMessageTimestamp = Date.now();
addHistoryItem(