run method

  1. @override
FutureOr? run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
FutureOr? run() {
  if (argResults!.rest.isEmpty) {
    print('Please specify a project name');
    return null;
  }

  final name = argResults!.rest.first;
  final gitUrl = argResults![_gitUrl] as String;
  _validateUrl(gitUrl);

  final dir = Directory(name);
  if (dir.existsSync()) {
    print('Directory $name already exists');
    exit(1);
  }

  print('Creating $name from $gitUrl');
  _cloneAndSetup(gitUrl, name);

  print('-----------------------------------');
  print('To run the project:');
  print('cd $name');
  print('arcade serve');
}