process method

Future<void> process(
  1. List<String> args
)

Implementation

Future<void> process(List<String> args) async {
  final cliArgs = parseCliArgs(args);

  if (cliArgs.showHelp) {
    showUsage();
    return;
  }

  if (cliArgs.showVersion) {
    showVersion();
    return;
  }

  final versioner = versionerProvider(cliArgs.toConfig())!;

  if (cliArgs.fullOutput) {
    logger.stdOut(
      trimLines(
        '''
      versionCode: ${await versioner.revision}
      versionName: ${await versioner.versionName}
      baseBranch: ${await versioner.baseBranch}
      currentBranch: ${await versioner.headBranchName}
      sha1: ${await versioner.sha1}
      sha1Short: ${(await versioner.sha1)?.substring(0, 7)}
      completeFirstOnlyBaseBranchCommitCount: ${(await versioner.allFirstBaseBranchCommits).length}
      baseBranchCommitCount: ${(await versioner.baseBranchCommits).length}
      baseBranchTimeComponent: ${await versioner.baseBranchTimeComponent}
      featureBranchCommitCount: ${(await versioner.featureBranchCommits).length}
      featureBranchTimeComponent: ${await versioner.featureBranchTimeComponent}
      featureOrigin: ${(await versioner.featureBranchOrigin)?.sha1}
      yearFactor: ${versioner.config.yearFactor}
      localChanges: ${await versioner.localChanges}
      ''',
      ),
    );
  } else {
    // default output
    final revision = await versioner.versionName;
    logger.stdOut(revision);
  }
}