Line data Source code
1 : import type { DashQLShellCommand } from '../../shell/api.js';
2 :
3 : export interface FormatCommandDependencies {
4 : requestDialog(signal?: AbortSignal): Promise<void>;
5 : }
6 :
7 1 : export function createFormatCommand(dependencies: FormatCommandDependencies): DashQLShellCommand {
8 1 : return [
9 1 : 'format',
10 1 : 'Open the SQL formatter',
11 1 : async (args, context) => {
12 1 : if (args.length !== 0) throw new Error('usage: .format');
13 1 : if (context.signal?.aborted) return;
14 1 : await dependencies.requestDialog(context.signal);
15 1 : },
16 1 : ];
17 1 : }
|