run method

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

Runs this command.

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

Implementation

@override
Future<void> run() async {
  final noCommit = argResults!['no-commit'] as bool;
  final noTag = argResults!['no-tag'] as bool;
  final dryRun = argResults!['dry-run'] as bool;
  final push = argResults!['push'] as bool;
  final noChangelog = argResults!['no-changelog'] as bool;

  if (argResults!.rest.isEmpty) {
    throw UsageException('You must specify bump type: major, minor, or patch', usage);
  }

  final bumpType = argResults!.rest.first;
  final validBumps = ['major', 'minor', 'patch'];

  if (!validBumps.contains(bumpType)) {
    throw UsageException(
      'Invalid bump type: "$bumpType". Must be one of: major, minor, patch',
      usage,
    );
  }

  final executor = dryRun ? DryRunReleaseExecutor() : RealReleaseExecutor();
  final service = VersionService(executor);

  await service.runRelease(
    bumpType,
    noCommit: noCommit,
    noTag: noTag,
    push: push,
    noChangelog: noChangelog || dryRun
  );
}