public async Task OnExecute(CommandLineApplication app, IConsole console) { var utils = new WorkrootCommandUtils(app, console); IEnumerable <WorkRoot> workroots = await utils.GetWorkRootsAsync(CommandAborded); foreach (WorkRoot wr in workroots) { await _localRepositoryIndexer.IndexWorkRootAsync( wr, onProgress : (msg) => console.WriteLine(msg), CommandAborded); } console.WriteLine("Repo indexing completed", ConsoleColor.Green); }
public async Task <int> IndexWorkRootsAsync( [Service] IHubContext <ConsoleHub> hubContext, [Service] ILocalRepositoryIndexer repositoryIndexer, [Service] IUserSettingsManager settingsManager, CancellationToken cancellationToken) { UserSettings settings = await settingsManager.GetAsync(cancellationToken); var session = new MessageSession(); Action <string> handler = async(string msg) => { await hubContext.Clients.All.SendAsync("consoleData", new ShellMessage(session.Next(), "Info", msg)); }; int indexCount = 0; foreach (WorkRoot wr in settings.WorkRoots) { var count = await repositoryIndexer.IndexWorkRootAsync( wr, handler, cancellationToken); indexCount += count; } await hubContext.Clients.All.SendAsync("consoleData", new ShellMessage(session.Next(), "end", $"Scan completed: {indexCount}") { Tags = new string[] { "success" } }); return(indexCount); }