Future printVersion()

in dartfn/lib/src/cli/command/version.dart [50:78]


Future<void> printVersion(
  CommandContext context, {
  bool short = false,
  bool checkUpdates = false,
}) async {
  final name = context.app.name;
  final version = context.app.version;

  if (short) {
    return context.console.write(version);
  }

  context.console
      .write('Functions Framework for Dart CLI ($name) version: $version');

  if (!checkUpdates) return;

  return Future(() async {
    // TODO: Don't say a "later" version is available in certain situations.
    // For example: when current version is "0.3.0-dev" and latest published is
    // "0.2.0".
    final latest = await checkPubForLaterVersion(name, version);
    if (latest != null) {
      context.console.write(
          'Version $latest is available! To update to this version, run: '
          '`pub global activate $name`.');
    }
  });
}