updated /quit to use new slash command arch (#4259)

Co-authored-by: Abhi <abhipatel@google.com>
This commit is contained in:
Harold Mciver
2025-07-16 22:40:56 -04:00
committed by GitHub
parent 01e66bb123
commit 9ab44ea9d6
8 changed files with 120 additions and 99 deletions

View File

@@ -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,
},
],
};
},
};