summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/quitCommand.ts
diff options
context:
space:
mode:
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,
+ },
+ ],
+ };
+ },
+};