run method

  1. @override
Future<int> run()
override

Runs this command.

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

Implementation

@override
Future<int> run() async {
  try {
    final versionInfo = await _versionService.getVersionInfo();
    // Using print instead of logger.info if we want the exact formatting,
    // but logger.info is fine as it usually prints to stdout.
    _logger.info(versionInfo.toString());
    return 0;
  } on ReleaseManagerException catch (e) {
    _logger.err(e.message);
    if (e.details != null) {
      _logger.info(e.details.toString());
    }
    return 1;
  } catch (e) {
    _logger.err('An unexpected error occurred while detecting version: $e');
    return 1;
  }
}