Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to match Spectre.Console commit c62f79e #20

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/BuildDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,50 @@ 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:
path: |
.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 }}

4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<LangVersion>preview</LangVersion>
<Configuration>$(TargetFramework)</Configuration>
<Company>ChrisPulman</Company>
<NoWarn>CS1591;IDE0190;IDE1006;RCS1198</NoWarn>
<NoWarn>CS1591;IDE0190;IDE1006;RCS1198;SA1010</NoWarn>
<Nullable>enable</Nullable>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down Expand Up @@ -44,7 +44,7 @@
<ItemGroup>
<!--<Compile Update="**\*.cs" DependentUpon="I%(Filename).cs" />-->
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.2" PrivateAssets="All" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
29 changes: 14 additions & 15 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Nuke.Common;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
Expand All @@ -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<Build>(x => x.Compile);
Expand All @@ -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 => _ => _
Expand Down
6 changes: 3 additions & 3 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169;CA1822;IDE1006</NoWarn>
<NoWarn>CS0649;CS0169;CA1822;IDE1006;IDE0051</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<IsPackable>False</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CP.Nuke.BuildTools" Version="1.0.34" />
<PackageReference Include="CP.Nuke.BuildTools" Version="1.0.36" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" />
<PackageReference Include="Nuke.Common" Version="7.0.6" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "8.0.10",
"rollForward": "latestMinor"
}
}
2 changes: 1 addition & 1 deletion src/CombinedExample/CombinedExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>False</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion src/LiveExample/LiveExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>False</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/LiveTableExample/LiveTableExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>False</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ProgressExample/ProgressExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>False</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ProgressThreadExample/ProgressThreadExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>False</IsPackable>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/Spectre.Console.Rx/Spectre.Console.Rx.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="Wcwidth.Sources" Version="1.0.0">
<PackageReference Include="Wcwidth.Sources" Version="2.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Spectre.Console.Rx/Spectre.Console/AnsiConsoleOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public bool IsTerminal
}

/// <inheritdoc/>
public int Width => ConsoleHelper.GetSafeWidth(Constants.DefaultTerminalWidth);
public int Width => ConsoleHelper.GetSafeWidth();

/// <inheritdoc/>
public int Height => ConsoleHelper.GetSafeHeight(Constants.DefaultTerminalWidth);
public int Height => ConsoleHelper.GetSafeHeight();

/// <inheritdoc/>
public void SetEncoding(Encoding encoding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Spectre.Console.Rx.Enrichment;

internal static class ProfileEnricher
{
private static readonly List<IProfileEnricher> _defaultEnrichers = new()
{
private static readonly List<IProfileEnricher> _defaultEnrichers =
[
new AppVeyorEnricher(),
new BambooEnricher(),
new BitbucketEnricher(),
Expand All @@ -20,7 +20,7 @@ internal static class ProfileEnricher
new TeamCityEnricher(),
new TfsEnricher(),
new TravisEnricher(),
};
];

public static void Enrich(
Profile profile,
Expand Down Expand Up @@ -67,7 +67,7 @@ private static List<IProfileEnricher> GetEnrichers(ProfileEnrichment settings)
return enrichers;
}

private static IDictionary<string, string> GetEnvironmentVariables(IDictionary<string, string>? variables)
private static Dictionary<string, string> GetEnvironmentVariables(IDictionary<string, string>? variables)
{
if (variables != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj, bool s
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static ConfirmationPrompt HideChoices(this ConfirmationPrompt obj) => ShowChoices(obj, false);

/// <summary>
/// Sets the style in which the list of choices is displayed.
/// </summary>
/// <param name="obj">The confirmation prompt.</param>
/// <param name="style">The style to use for displaying the choices or <see langword="null"/> to use the default style (blue).</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static ConfirmationPrompt ChoicesStyle(this ConfirmationPrompt obj, Style? style)
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}

obj.ChoicesStyle = style;
return obj;
}

/// <summary>
/// Show or hide the default value.
/// </summary>
Expand Down Expand Up @@ -70,6 +87,23 @@ public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj, b
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static ConfirmationPrompt HideDefaultValue(this ConfirmationPrompt obj) => ShowDefaultValue(obj, false);

/// <summary>
/// Sets the style in which the default value is displayed.
/// </summary>
/// <param name="obj">The confirmation prompt.</param>
/// <param name="style">The default value style or <see langword="null"/> to use the default style (green).</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static ConfirmationPrompt DefaultValueStyle(this ConfirmationPrompt obj, Style? style)
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}

obj.DefaultValueStyle = style;
return obj;
}

/// <summary>
/// Sets the "invalid choice" message for the prompt.
/// </summary>
Expand Down Expand Up @@ -120,4 +154,4 @@ public static ConfirmationPrompt No(this ConfirmationPrompt obj, char character)
obj.No = character;
return obj;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, double> _taskMilestones;
private readonly object _lock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ public sealed class ConfirmationPrompt(string prompt) : IPrompt<bool>
/// </summary>
public bool ShowDefaultValue { get; set; } = true;

/// <summary>
/// Gets or sets the style in which the default value is displayed. Defaults to green when <see langword="null"/>.
/// </summary>
public Style? DefaultValueStyle { get; set; }

/// <summary>
/// Gets or sets the style in which the list of choices is displayed. Defaults to blue when <see langword="null"/>.
/// </summary>
public Style? ChoicesStyle { get; set; }

/// <summary>
/// Gets or sets the string comparer to use when comparing user input
/// against Yes/No choices.
Expand All @@ -67,8 +77,10 @@ public async Task<bool> 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);

Expand Down
4 changes: 2 additions & 2 deletions src/Spectre.Console.Rx/Spectre.Console/Prompts/TextPrompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public sealed class TextPrompt<T>(string prompt, StringComparer? comparer = null
public Func<T, ValidationResult>? Validator { get; set; }

/// <summary>
/// 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 <see langword="null"/>.
/// </summary>
public Style? DefaultValueStyle { get; set; }

/// <summary>
/// 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 <see langword="null"/>.
/// </summary>
public Style? ChoicesStyle { get; set; }

Expand Down
Loading
Loading