This repository has been archived on 2026-02-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
siri-shortcuts/utils/registry.ts
Riccardo Senica 7d1ef8a7e5
Some checks failed
Deploy / lint-build-deploy (push) Failing after 57s
feat: use llama
2026-02-01 13:03:51 +01:00

32 lines
855 B
TypeScript

import { ShortcutsResponse } from './types';
import { pingCommand } from './commands/ping';
import { timeCommand } from './commands/time';
import { llamaCommand } from './commands/llama';
type CommandHandler = (
parameters?: Record<string, string>
) => Promise<ShortcutsResponse>;
export class CommandRegistry {
private commands: Map<string, CommandHandler>;
constructor() {
this.commands = new Map();
this.registerDefaultCommands();
}
private registerDefaultCommands() {
this.register('ping', pingCommand);
this.register('time', timeCommand);
this.register('llama', llamaCommand);
}
register(command: string, handler: CommandHandler) {
this.commands.set(command.toLowerCase(), handler);
}
getCommand(command: string): CommandHandler | undefined {
return this.commands.get(command.toLowerCase());
}
}