- @override
Handles the command input.
Override this method to perform actions for this command.
Return value is the value returned to the command line operation. Return 0 for success.
Source
@override
Future<int> handle() async {
if (projectName == null) {
printHelp(parentCommandName: "aqueduct");
return 1;
}
if (!isSnakeCase(projectName)) {
displayError("Invalid project name ($projectName is not snake_case).");
return 1;
}
var destDirectory = destinationDirectoryFromPath(projectName);
if (destDirectory.existsSync()) {
displayError("${destDirectory.path} already exists, stopping.");
return 1;
}
destDirectory.createSync();
var aqueductPath = await determineAqueductPath(
destDirectory, aqueductDependencyString,
offline: offline);
var sourceDirectory = new Directory(
path_lib.join(aqueductPath, "example", "templates", templateName));
if (templateDirectory != null) {
sourceDirectory =
new Directory(path_lib.join(templateDirectory, templateName));
}
if (!sourceDirectory.existsSync()) {
displayError("No template at ${sourceDirectory.path}.");
return 1;
}
displayProgress("Template source is: ${sourceDirectory.path}");
displayProgress("See more templates with 'aqueduct create list-templates'");
copyProjectFiles(destDirectory, sourceDirectory, projectName);
createProjectSpecificFiles(destDirectory.path, aqueductDependencyString);
replaceAqueductDependencyString(
destDirectory.path, aqueductDependencyString);
displayInfo(
"Fetching project dependencies (pub get --no-packages-dir ${offline ? "--offline" : ""})...");
await runPubGet(destDirectory, offline: offline);
displayProgress("Success.");
displayInfo("New project '$projectName' successfully created.");
displayProgress("Project is located at ${destDirectory.path}");
displayProgress("Open this directory in IntelliJ IDEA, Atom or VS Code.");
displayProgress(
"See ${destDirectory.path}${path_lib.separator}README.md for more information.");
return 0;
}