From 5bc0a0bfcf05826bc3239ba068b85dd9bd9927ae Mon Sep 17 00:00:00 2001 From: Donald Pakkies Date: Thu, 14 Sep 2023 11:43:21 +0200 Subject: [PATCH] feat: add event command base file --- .../Console/Commands/EventCommand.imba | 25 +++++++++++++++++++ .../Console/Commands/EventCommand.d.ts | 13 ++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/Foundation/Console/Commands/EventCommand.imba create mode 100644 types/Foundation/Console/Commands/EventCommand.d.ts diff --git a/src/Foundation/Console/Commands/EventCommand.imba b/src/Foundation/Console/Commands/EventCommand.imba new file mode 100644 index 00000000..3513de5e --- /dev/null +++ b/src/Foundation/Console/Commands/EventCommand.imba @@ -0,0 +1,25 @@ +import { Command } from '../Command' +import { Prop } from '@formidablejs/console' + +export class EventCommand < Command + + get signature + event + ' {--dev} {--port=} {--host=} {--noAnsi}' + + get props + { + dev: Prop.boolean().default(false) + port: Prop.number().default(3000) + host: Prop.string().default('localhost') + noAnsi: Prop.boolean().default(false) + } + + def handle + const dev = self.option('dev') + const port = self.option('port') + const host = self.option('host') + const noAnsi = self.option('noAnsi') + + if persist then return persist(dev, port, host, noAnsi) + + self.error('No event handler found') diff --git a/types/Foundation/Console/Commands/EventCommand.d.ts b/types/Foundation/Console/Commands/EventCommand.d.ts new file mode 100644 index 00000000..59af1d0b --- /dev/null +++ b/types/Foundation/Console/Commands/EventCommand.d.ts @@ -0,0 +1,13 @@ +import { Command } from "../Command"; + +export class EventCommand extends Command { + /** + * The console command signature name. + */ + get event(): string; + + /** + * Execute event command. + */ + persist(dev: boolean, port: number, host: string, noAnsi: boolean): Promise; +}