run method

  1. @override
bool run()
override

Runs this command.

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

Implementation

@override
bool run() {
  var argResults = this.argResults!;
  var showGenerated = argResults['generated'] as bool;
  var showSources = argResults['original'] as bool;
  Iterable<AssetId> assets;
  if (showGenerated) {
    assets = assetGraph.outputs;
  } else if (showSources) {
    assets = assetGraph.sources;
  } else {
    assets = assetGraph.allNodes.map((n) => n.id);
  }

  var package = argResults['package'] as String?;
  if (package != null) {
    assets = assets.where((id) => id.package == package);
  }

  var pattern = argResults['pattern'] as String?;
  if (pattern != null) {
    var glob = Glob(pattern);
    assets = assets.where((id) => glob.matches(id.path));
  }

  for (var id in assets) {
    _listAsset(id, stdout, indentation: '  ');
  }
  return false;
}