run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<void> run() async {
final PubspecSource source = buildSource(argResults!);
if (argResults!.rest.isEmpty) {
throw ArgumentError('No output directory provided.');
}
final String outputDir = argResults!.rest.last;
print('Fetching pubspec files to "$outputDir"');
final uris = await source.fetchPubspecUris();
print('Found ${uris.length} pubspec files');
print('Downloading pubspec files to $outputDir');
for (final uri in uris) {
final file = File('$outputDir/${uri.toString().hashCode}.yaml');
if (!file.existsSync()) {
final content = await source.fetchPubspecContent(uri);
file.writeAsStringSync(content);
}
}
print('Downloaded ${uris.length} pubspec files to $outputDir');
}