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() async {
  final results = argResults;
  if (results == null) throw ArgumentError('No arguments provided');

  final isDryRun = results[argDryRun] as bool?;

  final dartDeploy = DartDeploy(
    isDryRun: isDryRun,
  );

  final dartBuild = DartBuild(
    appName: results[argAppName] as String,
    appVersion: results[argAppVersion] as String?,
    buildMetadata: results[argBuildMetadata] as String?,
    buildPreRelease: results[argBuildPreRelease] as String?,
    buildArgs: results[argBuildArg] as List<String>,
    mainPath: results[argMainPath] as String,
    includedPaths: results[argIncludePath] as List<String>,
    buildFolder: results[argBuildFolder] as String?,
    executableName: results[argExecName] as String?,
    releaseFolder: results[argReleaseFolder] as String?,
    dartSdkPath: results[argDartSdkPath] as String?,
  );

  final deploy = getDeploy(
      results: results, dartDeploy: dartDeploy, dartBuild: dartBuild);
  await deploy.deploy();
  if (isDryRun ?? false) {
    stdout.writeln('Dry run for ${deploy.runtimeType} was successful!');
  } else {
    stdout.writeln('Deploying to ${deploy.runtimeType} was successful!');
  }
}