run method

Future<int> run(
  1. List<String> args
)

Public method or function.

Implementation

Future<int> run(List<String> args) async {
  if (args.isEmpty) {
    printUsage();
    return AppConstants.exitNoIssues;
  }

  final commandName = args.first;
  final commandArgs = args.skip(1).toList();

  if (commandName == 'help') {
    final helpCmd = findCommand('help');
    if (helpCmd != null) {
      return helpCmd.execute(commandArgs);
    }
  }

  final command = findCommand(commandName);
  if (command == null) {
    terminal.writeError('Unknown command: $commandName\n');
    printUsage();
    return AppConstants.exitInternalFailure;
  }

  return command.execute(commandArgs);
}