diff --git a/.github/workflows/BuildDeploy.yml b/.github/workflows/BuildDeploy.yml index f396595..437bb97 100644 --- a/.github/workflows/BuildDeploy.yml +++ b/.github/workflows/BuildDeploy.yml @@ -25,10 +25,20 @@ jobs: windows-latest: name: windows-latest runs-on: windows-latest + environment: + name: release steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + + - name: NBGV + id: nbgv + uses: dotnet/nbgv@master + with: + setAllVars: true + - run: echo 'SemVer2=${{ steps.nbgv.outputs.SemVer2 }}' + - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v3 with: @@ -36,12 +46,29 @@ jobs: .nuke/temp ~/.nuget/packages key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} + - name: 'Run: Compile, Deploy' run: ./build.cmd Compile Deploy env: NuGetApiKey: ${{ secrets.NUGET_API_KEY }} + - name: 'Publish: output' uses: actions/upload-artifact@v3 with: name: output path: output + + - name: Changelog + uses: glennawatson/ChangeLog@v1 + id: changelog + + - name: Create Release + uses: actions/create-release@v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ steps.nbgv.outputs.SemVer2 }} + release_name: ${{ steps.nbgv.outputs.SemVer2 }} + body: | + ${{ steps.changelog.outputs.commitLog }} + diff --git a/Directory.Build.props b/Directory.Build.props index ad866af..957bbb8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,7 +9,7 @@ preview $(TargetFramework) ChrisPulman - CS1591;IDE0190;IDE1006;RCS1198 + CS1591;IDE0190;IDE1006;RCS1198;SA1010 enable logo.png README.md @@ -44,7 +44,7 @@ - + diff --git a/build/Build.cs b/build/Build.cs index 64209fb..ddd7c7f 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,5 +1,4 @@ using Nuke.Common; -using Nuke.Common.CI.GitHubActions; using Nuke.Common.Git; using Nuke.Common.IO; using Nuke.Common.ProjectModel; @@ -11,19 +10,19 @@ using Nuke.Common.Tools.PowerShell; using CP.BuildTools; -[GitHubActions( - "BuildOnly", - GitHubActionsImage.WindowsLatest, - OnPushBranchesIgnore = new[] { "main" }, - FetchDepth = 0, - InvokedTargets = new[] { nameof(Compile) })] -[GitHubActions( - "BuildDeploy", - GitHubActionsImage.WindowsLatest, - OnPushBranches = new[] { "main" }, - FetchDepth = 0, - ImportSecrets = new[] { nameof(NuGetApiKey) }, - InvokedTargets = new[] { nameof(Compile), nameof(Deploy) })] +////[GitHubActions( +//// "BuildOnly", +//// GitHubActionsImage.WindowsLatest, +//// OnPushBranchesIgnore = new[] { "main" }, +//// FetchDepth = 0, +//// InvokedTargets = new[] { nameof(Compile) })] +////[GitHubActions( +//// "BuildDeploy", +//// GitHubActionsImage.WindowsLatest, +//// OnPushBranches = new[] { "main" }, +//// FetchDepth = 0, +//// ImportSecrets = new[] { nameof(NuGetApiKey) }, +//// InvokedTargets = new[] { nameof(Compile), nameof(Deploy) })] partial class Build : NukeBuild { public static int Main() => Execute(x => x.Compile); @@ -50,7 +49,7 @@ partial class Build : NukeBuild } PackagesDirectory.CreateOrCleanDirectory(); - await this.InstallDotNetSdk("3.1.x", "5.x.x", "6.x.x", "7.x.x"); + await this.InstallDotNetSdk("6.x.x", "7.x.x", "8.x.x"); }); Target Restore => _ => _ diff --git a/build/_build.csproj b/build/_build.csproj index 7272d12..e56217d 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -2,9 +2,9 @@ Exe - net6.0 + net7.0 - CS0649;CS0169;CA1822;IDE1006 + CS0649;CS0169;CA1822;IDE1006;IDE0051 .. .. 1 @@ -12,7 +12,7 @@ - + diff --git a/global.json b/global.json new file mode 100644 index 0000000..4c31281 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "8.0.10", + "rollForward": "latestMinor" + } +} diff --git a/src/CombinedExample/CombinedExample.csproj b/src/CombinedExample/CombinedExample.csproj index c9de434..27c546f 100644 --- a/src/CombinedExample/CombinedExample.csproj +++ b/src/CombinedExample/CombinedExample.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable False diff --git a/src/LiveExample/LiveExample.csproj b/src/LiveExample/LiveExample.csproj index 4289849..8c9af43 100644 --- a/src/LiveExample/LiveExample.csproj +++ b/src/LiveExample/LiveExample.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 False diff --git a/src/LiveTableExample/LiveTableExample.csproj b/src/LiveTableExample/LiveTableExample.csproj index 4289849..8c9af43 100644 --- a/src/LiveTableExample/LiveTableExample.csproj +++ b/src/LiveTableExample/LiveTableExample.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 False diff --git a/src/ProgressExample/ProgressExample.csproj b/src/ProgressExample/ProgressExample.csproj index adcbbef..e4f20eb 100644 --- a/src/ProgressExample/ProgressExample.csproj +++ b/src/ProgressExample/ProgressExample.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 False diff --git a/src/ProgressThreadExample/ProgressThreadExample.csproj b/src/ProgressThreadExample/ProgressThreadExample.csproj index adcbbef..e4f20eb 100644 --- a/src/ProgressThreadExample/ProgressThreadExample.csproj +++ b/src/ProgressThreadExample/ProgressThreadExample.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 False diff --git a/src/Spectre.Console.Rx/Spectre.Console.Rx.csproj b/src/Spectre.Console.Rx/Spectre.Console.Rx.csproj index 0d71df3..ebfd4d5 100644 --- a/src/Spectre.Console.Rx/Spectre.Console.Rx.csproj +++ b/src/Spectre.Console.Rx/Spectre.Console.Rx.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net6.0;net7.0 + netstandard2.0;net6.0;net7.0;net8.0 enable enable @@ -13,7 +13,7 @@ - + all diff --git a/src/Spectre.Console.Rx/Spectre.Console/AnsiConsoleOutput.cs b/src/Spectre.Console.Rx/Spectre.Console/AnsiConsoleOutput.cs index 82f8d7e..8fca556 100644 --- a/src/Spectre.Console.Rx/Spectre.Console/AnsiConsoleOutput.cs +++ b/src/Spectre.Console.Rx/Spectre.Console/AnsiConsoleOutput.cs @@ -36,10 +36,10 @@ public bool IsTerminal } /// - public int Width => ConsoleHelper.GetSafeWidth(Constants.DefaultTerminalWidth); + public int Width => ConsoleHelper.GetSafeWidth(); /// - public int Height => ConsoleHelper.GetSafeHeight(Constants.DefaultTerminalWidth); + public int Height => ConsoleHelper.GetSafeHeight(); /// public void SetEncoding(Encoding encoding) diff --git a/src/Spectre.Console.Rx/Spectre.Console/Enrichment/ProfileEnricher.cs b/src/Spectre.Console.Rx/Spectre.Console/Enrichment/ProfileEnricher.cs index 1b53d2c..c4938f7 100644 --- a/src/Spectre.Console.Rx/Spectre.Console/Enrichment/ProfileEnricher.cs +++ b/src/Spectre.Console.Rx/Spectre.Console/Enrichment/ProfileEnricher.cs @@ -5,8 +5,8 @@ namespace Spectre.Console.Rx.Enrichment; internal static class ProfileEnricher { - private static readonly List _defaultEnrichers = new() - { + private static readonly List _defaultEnrichers = + [ new AppVeyorEnricher(), new BambooEnricher(), new BitbucketEnricher(), @@ -20,7 +20,7 @@ internal static class ProfileEnricher new TeamCityEnricher(), new TfsEnricher(), new TravisEnricher(), - }; + ]; public static void Enrich( Profile profile, @@ -67,7 +67,7 @@ private static List GetEnrichers(ProfileEnrichment settings) return enrichers; } - private static IDictionary GetEnvironmentVariables(IDictionary? variables) + private static Dictionary GetEnvironmentVariables(IDictionary? variables) { if (variables != null) { diff --git a/src/Spectre.Console.Rx/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs b/src/Spectre.Console.Rx/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs index aa5c174..6445f2a 100644 --- a/src/Spectre.Console.Rx/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs +++ b/src/Spectre.Console.Rx/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs @@ -39,6 +39,23 @@ public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj, bool s /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt HideChoices(this ConfirmationPrompt obj) => ShowChoices(obj, false); + /// + /// Sets the style in which the list of choices is displayed. + /// + /// The confirmation prompt. + /// The style to use for displaying the choices or to use the default style (blue). + /// The same instance so that multiple calls can be chained. + public static ConfirmationPrompt ChoicesStyle(this ConfirmationPrompt obj, Style? style) + { + if (obj is null) + { + throw new ArgumentNullException(nameof(obj)); + } + + obj.ChoicesStyle = style; + return obj; + } + /// /// Show or hide the default value. /// @@ -70,6 +87,23 @@ public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj, b /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt HideDefaultValue(this ConfirmationPrompt obj) => ShowDefaultValue(obj, false); + /// + /// Sets the style in which the default value is displayed. + /// + /// The confirmation prompt. + /// The default value style or to use the default style (green). + /// The same instance so that multiple calls can be chained. + public static ConfirmationPrompt DefaultValueStyle(this ConfirmationPrompt obj, Style? style) + { + if (obj is null) + { + throw new ArgumentNullException(nameof(obj)); + } + + obj.DefaultValueStyle = style; + return obj; + } + /// /// Sets the "invalid choice" message for the prompt. /// @@ -120,4 +154,4 @@ public static ConfirmationPrompt No(this ConfirmationPrompt obj, char character) obj.No = character; return obj; } -} \ No newline at end of file +} diff --git a/src/Spectre.Console.Rx/Spectre.Console/Live/Progress/Renderers/FallbackProgressRenderer.cs b/src/Spectre.Console.Rx/Spectre.Console/Live/Progress/Renderers/FallbackProgressRenderer.cs index 3548cfd..b9c6104 100644 --- a/src/Spectre.Console.Rx/Spectre.Console/Live/Progress/Renderers/FallbackProgressRenderer.cs +++ b/src/Spectre.Console.Rx/Spectre.Console/Live/Progress/Renderers/FallbackProgressRenderer.cs @@ -6,7 +6,7 @@ namespace Spectre.Console.Rx; internal sealed class FallbackProgressRenderer : ProgressRenderer { private const double FirstMilestone = 25; - private static readonly double?[] _milestones = new double?[] { FirstMilestone, 50, 75, 95, 96, 97, 98, 99, 100 }; + private static readonly double?[] _milestones = [FirstMilestone, 50, 75, 95, 96, 97, 98, 99, 100]; private readonly Dictionary _taskMilestones; private readonly object _lock; diff --git a/src/Spectre.Console.Rx/Spectre.Console/Prompts/ConfirmationPrompt.cs b/src/Spectre.Console.Rx/Spectre.Console/Prompts/ConfirmationPrompt.cs index 3af6664..95d909f 100644 --- a/src/Spectre.Console.Rx/Spectre.Console/Prompts/ConfirmationPrompt.cs +++ b/src/Spectre.Console.Rx/Spectre.Console/Prompts/ConfirmationPrompt.cs @@ -46,6 +46,16 @@ public sealed class ConfirmationPrompt(string prompt) : IPrompt /// public bool ShowDefaultValue { get; set; } = true; + /// + /// Gets or sets the style in which the default value is displayed. Defaults to green when . + /// + public Style? DefaultValueStyle { get; set; } + + /// + /// Gets or sets the style in which the list of choices is displayed. Defaults to blue when . + /// + public Style? ChoicesStyle { get; set; } + /// /// Gets or sets the string comparer to use when comparing user input /// against Yes/No choices. @@ -67,8 +77,10 @@ public async Task ShowAsync(IAnsiConsole console, CancellationToken cancel .InvalidChoiceMessage(InvalidChoiceMessage) .ValidationErrorMessage(InvalidChoiceMessage) .ShowChoices(ShowChoices) + .ChoicesStyle(ChoicesStyle) .ShowDefaultValue(ShowDefaultValue) .DefaultValue(DefaultValue ? Yes : No) + .DefaultValueStyle(DefaultValueStyle) .AddChoice(Yes) .AddChoice(No); diff --git a/src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPrompt.cs b/src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPrompt.cs index ddaf4cb..58ae09a 100644 --- a/src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPrompt.cs +++ b/src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPrompt.cs @@ -82,12 +82,12 @@ public sealed class TextPrompt(string prompt, StringComparer? comparer = null public Func? Validator { get; set; } /// - /// Gets or sets the style in which the default value is displayed. + /// Gets or sets the style in which the default value is displayed. Defaults to green when . /// public Style? DefaultValueStyle { get; set; } /// - /// Gets or sets the style in which the list of choices is displayed. + /// Gets or sets the style in which the list of choices is displayed. Defaults to blue when . /// public Style? ChoicesStyle { get; set; } diff --git a/src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPromptExtensions.cs b/src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPromptExtensions.cs index 263afdc..c428819 100644 --- a/src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPromptExtensions.cs +++ b/src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPromptExtensions.cs @@ -318,20 +318,15 @@ public static TextPrompt WithConverter(this TextPrompt obj, Func /// The prompt result type. /// The prompt. - /// The default value style. + /// The default value style or to use the default style (green). /// The same instance so that multiple calls can be chained. - public static TextPrompt DefaultValueStyle(this TextPrompt obj, Style style) + public static TextPrompt DefaultValueStyle(this TextPrompt obj, Style? style) { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } - if (style is null) - { - throw new ArgumentNullException(nameof(style)); - } - obj.DefaultValueStyle = style; return obj; } @@ -341,20 +336,15 @@ public static TextPrompt DefaultValueStyle(this TextPrompt obj, Style s /// /// The prompt result type. /// The prompt. - /// The style to use for displaying the choices. + /// The style to use for displaying the choices or to use the default style (blue). /// The same instance so that multiple calls can be chained. - public static TextPrompt ChoicesStyle(this TextPrompt obj, Style style) + public static TextPrompt ChoicesStyle(this TextPrompt obj, Style? style) { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } - if (style is null) - { - throw new ArgumentNullException(nameof(style)); - } - obj.ChoicesStyle = style; return obj; } diff --git a/src/StatusExample/StatusExample.csproj b/src/StatusExample/StatusExample.csproj index adcbbef..e4f20eb 100644 --- a/src/StatusExample/StatusExample.csproj +++ b/src/StatusExample/StatusExample.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 False