summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/quitCommand.ts
diff options
context:
space:
mode:
authorHarold Mciver <[email protected]>2025-07-16 22:40:56 -0400
committerGitHub <[email protected]>2025-07-17 02:40:56 +0000
commit9ab44ea9d675cd9d560e22fba50d057f1764f25c (patch)
tree492c12bd893fe0249545a2b4b16a86b11ca86fd1 /packages/cli/src/ui/commands/quitCommand.ts
parent01e66bb12392c3e8cd0222dc495c8dc61ebe4fba (diff)
updated `/quit` to use new slash command arch (#4259)
Co-authored-by: Abhi <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/commands/quitCommand.ts')
-rw-r--r--packages/cli/src/ui/commands/quitCommand.ts35
1 files changed, 35 insertions, 0 deletions
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,
+ },
+ ],
+ };
+ },
+};