run method

void run(
  1. List<String> arguments
)

Runs the project structure builder.

This method checks the command line arguments and runs the UpdateCommand if the command is "update". If the command is "help", it prints the help message. Otherwise, it prints an error message.

The method also prints the initialization message.

Implementation

void run(List<String> arguments) {
  try {
    print(
      "PROJECT STRUCTURE BUILDER - Flutter Project Structure Generator\n"
      "Initialization... \n"
      "Usage: dart run project_structure_builder <command> $arguments"
    );

    if (arguments.isEmpty) {
      print("No command specified. Use ''update'' to update the project.");
      return;
    }

    final command = UpdateCommand();

    if (arguments.isNotEmpty && arguments[0] == 'update') {
      command.run(arguments);
    } else if (arguments.isNotEmpty && (arguments[0] == 'h' || arguments[0] == 'help')) {
      command.help();
    } else {
      print("Unknown command.");
    }
  } on Exception catch (e) {
    print(": $e");
  }
}