mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-10-25 15:19:23 +00:00
Add top-level CancellationToken support to Spectre.Console.Cli
Also raise CA2016 (forward the CancellationToken parameter to methods that take one) to warning Fixes #701
This commit is contained in:
committed by
Patrik Svensson
parent
d90e94dbb3
commit
f5f61ca610
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Generator.Models;
|
||||
using Scriban;
|
||||
using Spectre.Console.Cli;
|
||||
@@ -21,7 +22,7 @@ namespace Generator.Commands
|
||||
public string Input { get; set; }
|
||||
}
|
||||
|
||||
public override int Execute(CommandContext context, Settings settings)
|
||||
public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
var templates = new FilePath[]
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AngleSharp.Html.Parser;
|
||||
using Generator.Models;
|
||||
@@ -39,7 +40,7 @@ namespace Generator.Commands
|
||||
_parser = new HtmlParser();
|
||||
}
|
||||
|
||||
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings)
|
||||
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
var output = new DirectoryPath(settings.Output);
|
||||
if (!_fileSystem.Directory.Exists(settings.Output))
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Generator.Commands.Samples;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
@@ -38,7 +39,7 @@ namespace Generator.Commands
|
||||
_console = new AsciiCastConsole(console);
|
||||
}
|
||||
|
||||
public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings)
|
||||
public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
var samples = typeof(BaseSample).Assembly
|
||||
.GetTypes()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Generator.Models;
|
||||
using Scriban;
|
||||
using Spectre.Console.Cli;
|
||||
@@ -16,7 +17,7 @@ namespace Generator.Commands
|
||||
_fileSystem = new FileSystem();
|
||||
}
|
||||
|
||||
public override int Execute(CommandContext context, GeneratorSettings settings)
|
||||
public override int Execute(CommandContext context, GeneratorSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
// Read the spinner model.
|
||||
var spinners = new List<Spinner>();
|
||||
|
||||
Reference in New Issue
Block a user