Update plugin boilerplate

This commit is contained in:
Tobe O 2018-07-14 19:26:05 -04:00
parent d6568c53a0
commit c199e56e14
2 changed files with 14 additions and 6 deletions

View file

@ -64,12 +64,21 @@ class ControllerCommand extends Command {
: 'Controller'); : 'Controller');
if (argResults['websocket'] as bool) { 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) { clazz.methods.add(new Method((meth) {
meth meth
..name = 'hello' ..name = 'hello'
..returns = refer('void') ..returns = refer('void')
..annotations.add(refer('ExposeWs') ..annotations
.call([literal('get_${rc.snakeCase}')])) .add(refer('ExposeWs').call([literal('get_${rc.snakeCase}')]))
..requiredParameters.add(new Parameter((b) => b ..requiredParameters.add(new Parameter((b) => b
..name = 'socket' ..name = 'socket'
..type = refer('WebSocketContext'))) ..type = refer('WebSocketContext')))

View file

@ -60,11 +60,10 @@ library ${pubspec.name}.src.config.plugins.${rc.snakeCase};
import 'dart:async'; import 'dart:async';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel_framework/angel_framework.dart';
class ${rc.pascalCase}Plugin extends AngelPlugin { AngelConfigurer ${rc.camelCase}() {
@override return (Angel app) async {
Future call(Angel app) async {
// Work some magic... // Work some magic...
} };
} }
'''; ''';
} }