From 9ab44ea9d675cd9d560e22fba50d057f1764f25c Mon Sep 17 00:00:00 2001 From: Harold Mciver Date: Wed, 16 Jul 2025 22:40:56 -0400 Subject: updated `/quit` to use new slash command arch (#4259) Co-authored-by: Abhi --- packages/cli/src/ui/commands/quitCommand.ts | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packages/cli/src/ui/commands/quitCommand.ts (limited to 'packages/cli/src/ui/commands/quitCommand.ts') diff --git a/packages/cli/src/ui/commands/quitCommand.ts b/packages/cli/src/ui/commands/quitCommand.ts new file mode 100644 index 00000000..48daf8c2 --- /dev/null +++ b/packages/cli/src/ui/commands/quitCommand.ts @@ -0,0 +1,35 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { formatDuration } from '../utils/formatters.js'; +import { type SlashCommand } from './types.js'; + +export const quitCommand: SlashCommand = { + name: 'quit', + altName: 'exit', + description: 'exit the cli', + action: (context) => { + const now = Date.now(); + const { sessionStartTime } = context.session.stats; + const wallDuration = now - sessionStartTime.getTime(); + + return { + type: 'quit', + messages: [ + { + type: 'user', + text: `/quit`, // Keep it consistent, even if /exit was used + id: now - 1, + }, + { + type: 'quit', + duration: formatDuration(wallDuration), + id: now, + }, + ], + }; + }, +}; -- cgit v1.2.3