1. @override
Future<int> handle()

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 aqueductDirectory = aqueductPackageRef.resolve().location;
  displayProgress("Aqueduct directory is: ${aqueductDirectory.path}");
  var templateURI = aqueductDirectory.uri
      .resolve("example/").resolve("templates/").resolve(templateName + "/");
  var templateSourceDirectory = new Directory.fromUri(templateURI);

  if (!templateSourceDirectory.existsSync()) {
    displayError("No template at ${templateSourceDirectory.path}.");
    return 1;
  }

  displayProgress("Template source is: ${templateSourceDirectory.path}");
  displayProgress("See more templates with 'aqueduct create list-templates'");
  copyProjectFiles(destDirectory, templateSourceDirectory, projectName);

  createProjectSpecificFiles(destDirectory.path);
  replaceAqueductDependencyString(
      destDirectory.path, getAqueductDependencyStringFromPackage(aqueductPackageRef));

  displayInfo(
      "Fetching project dependencies (pub get --no-packages-dir ${offline ? "--offline" : ""})...");
  try {
    await runPubGet(destDirectory, offline: offline);
  } on TimeoutException {
    displayInfo("Fetching dependencies timed out. Run 'pub get' in your project directory.");
  }

  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;
}