run method
Runs this command.
The return value is wrapped in a Future
if necessary and returned by
CommandRunner.runCommand
.
Implementation
@override
Future<ExitCode> run() async {
final packageName = lightGreen.wrap('sip_cli')!;
final progress = logger.progress('Checking for updates');
final (needsUpdate, latestVersion) = await this.needsUpdate();
if (!needsUpdate) {
final version = darkGray.wrap('(v$packageVersion)');
progress.complete(
'$packageName is up to date $version',
);
return ExitCode.success;
}
progress.update('Updating $packageName to ${yellow.wrap(latestVersion)}');
final updatedSuccessfully = await update();
if (!updatedSuccessfully) {
progress.complete('Failed to update $packageName');
return ExitCode.software;
}
progress.complete(
'Successfully updated $packageName to ${yellow.wrap(latestVersion)}',
);
return ExitCode.success;
}