/// <inheritdoc /> protected override int Execute(IInput input, IOutput output) { var platformRepository = new RepositoryPlatform(); var io = GetIO(); var bucket = GetBucket(false); if (!bucket) { var factory = new Factory(); bucket = factory.CreateBucket(io, new ConfigBucket(), input.HasRawOption("--no-plugins")); } var localInstalledRepository = bucket.GetRepositoryManager().GetLocalInstalledRepository(); var repositoryInstalled = new RepositoryComposite(localInstalledRepository, platformRepository); var repositories = new RepositoryComposite(Arr.Merge(new[] { repositoryInstalled }, bucket.GetRepositoryManager().GetRepositories())); var commandEvent = new CommandEventArgs(PluginEvents.Command, "search", input, output); bucket.GetEventDispatcher().Dispatch(this, commandEvent); var flags = input.GetOption("only-name") ? SearchMode.Name : SearchMode.Fulltext; var results = repositories.Search(string.Join(Str.Space, input.GetArgument("tokens")), flags, input.GetOption("type")); var seed = new HashSet <string>(); foreach (var result in results) { if (!seed.Add(result.GetName())) { continue; } io.Write(result.ToString()); } return(ExitCodes.Normal); }
public void TestNoRepositoriesSearch() { CollectionAssert.AreEqual(Array.Empty <SearchResult>(), repositoryComposite.Search("foo")); }