public override async ValueTask ExecuteAsync(IConsole console) { var pipeMethods = PipeCtx.PipeMethods(); var runId = RunId.HasValue() ? PipeRunId.FromString(RunId) : new(); if (RunId.NullOrEmpty()) { throw new CommandException($"Provide one of the following pipes to run: {pipeMethods.Join(", ", m => m.Method.Name)}"); } if (!pipeMethods.ContainsKey(runId.Name)) { throw new CommandException($"Pipe {runId.Name} not found. Available: {pipeMethods.Join(", ", m => m.Method.Name)}"); } var log = Log.ForContext("RunId", runId); log.Information("Pipe Run Command Started {RunId}", RunId); if (runId.HasGroup) { await PipeCtx.DoPipeWork(runId, console.GetCancellationToken()); } else { var res = await PipeCtx.Run(runId.Name, new() { Location = Location ?? PipeRunLocation.Local }, log : log, cancel : console.GetCancellationToken()); if (res.Error) { throw new CommandException(res.ErrorMessage); } } }
public async ValueTask ExecuteAsync(IConsole console) { console.GetCancellationToken().Register(() => Log.Information("Cancellation requested")); var options = new UpdateOptions { Actions = Actions?.UnJoin('|'), Channels = Channels?.UnJoin('|'), Tables = Tables?.UnJoin('|'), Results = Results?.UnJoin('|'), FullLoad = FullLoad, DisableChannelDiscover = DisableChannelDiscover, SearchConditions = SearchConditions?.UnJoin('|').Select(t => { var(index, condition, _) = t.UnJoin(':'); return(index.ParseEnum <SearchIndex>(), condition); }).ToArray(), }; await PipeCtx.Run((YtUpdater u) => u.Update(options, PipeArg.Inject <CancellationToken>()), new PipeRunOptions { Location = Location, Exclusive = true }, Log, console.GetCancellationToken()); }