execute method
Implementation
@override
Future<void> execute(AFCommandContext context) async {
final unnamed = context.rawArgs;
if(unnamed.isEmpty) {
throwUsageError("Expected one arguments");
}
final commandName = unnamed[0];
verifyEndsWith(commandName, "Command");
final generator = context.generator;
final commandNameShort = generator.removeSuffix(commandName, "Command");
// generate the command file itself.
final fileCommand = context.createFile(generator.pathCommand(commandName), CommandT(), insertions: {
CommandT.insertCommandName: commandName,
CommandT.insertCommandNameShort: commandNameShort,
});
// register it
final fileExtend = generator.modifyFile(context, generator.pathExtendCommand);
fileExtend.importFile(context, fileCommand);
final declareDefine = context.createSnippet(SnippetCallDefineCommandT(), insertions: {
CommandT.insertCommandName: commandName,
});
fileExtend.addLinesAfter(context, AFCodeRegExp.startExtendCommand, declareDefine.lines);
// replace any default
generator.finalizeAndWriteFiles(context);
}