run method

  1. @override
void run()
override

Runs this command.

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

Implementation

@override
void run() async {
  // Show a tip about using the "ref" alias instead of "refresh".
  if (argResults!.name == 'refresh') {
    final cacheName = 'tip_refresh_ref_shown';

    final bool shown = await Setting.get(cacheName, defaultValue: false);
    if (!shown) {
      final tip = 'You can use the alias "ref" instead of "refresh"';
      Logger.tip(tip);
      final nextWeek = DateTime.now().add(Duration(days: 7));
      Setting.set(cacheName, true, expires: nextWeek, lazy: true);
    }
  }

  // Refresh the package list.
  await Repositories.index();
}