From c199e56e141603fa798effeb031418c88a80bfe7 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sat, 14 Jul 2018 19:26:05 -0400 Subject: [PATCH] Update plugin boilerplate --- lib/src/commands/make/controller.dart | 13 +++++++++++-- lib/src/commands/make/plugin.dart | 7 +++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/src/commands/make/controller.dart b/lib/src/commands/make/controller.dart index 58a1d25..f5746d6 100644 --- a/lib/src/commands/make/controller.dart +++ b/lib/src/commands/make/controller.dart @@ -64,12 +64,21 @@ class ControllerCommand extends Command { : 'Controller'); if (argResults['websocket'] as bool) { + // XController(AngelWebSocket ws) : super(ws); + clazz.constructors.add(new Constructor((b) { + b + ..requiredParameters.add(new Parameter((b) => b + ..name = 'ws' + ..type = refer('AngelWebSocket'))) + ..initializers.add(new Code('super(ws)')); + })); + clazz.methods.add(new Method((meth) { meth ..name = 'hello' ..returns = refer('void') - ..annotations.add(refer('ExposeWs') - .call([literal('get_${rc.snakeCase}')])) + ..annotations + .add(refer('ExposeWs').call([literal('get_${rc.snakeCase}')])) ..requiredParameters.add(new Parameter((b) => b ..name = 'socket' ..type = refer('WebSocketContext'))) diff --git a/lib/src/commands/make/plugin.dart b/lib/src/commands/make/plugin.dart index 3780750..d942435 100644 --- a/lib/src/commands/make/plugin.dart +++ b/lib/src/commands/make/plugin.dart @@ -60,11 +60,10 @@ library ${pubspec.name}.src.config.plugins.${rc.snakeCase}; import 'dart:async'; import 'package:angel_framework/angel_framework.dart'; -class ${rc.pascalCase}Plugin extends AngelPlugin { - @override - Future call(Angel app) async { +AngelConfigurer ${rc.camelCase}() { + return (Angel app) async { // Work some magic... - } + }; } '''; }