Skip to content

Commit 0149c3a

Browse files
committed
Upgrade to .net 10
1 parent bf3d9cb commit 0149c3a

8 files changed

Lines changed: 26 additions & 361 deletions

File tree

.editorconfig

Lines changed: 1 addition & 348 deletions
Large diffs are not rendered by default.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v4
2121
with:
22-
dotnet-version: 8.0.x
22+
dotnet-version: 10.0.x
2323
- name: Restore dependencies
2424
run: dotnet restore
2525
- name: Build

Directory.Build.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<Project>
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<OutputType>Exe</OutputType>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Deterministic>true</Deterministic>
77
<RunCodeAnalysis>true</RunCodeAnalysis>
8+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
89
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
910
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1011
<MSBuildTreatWarningsAsErrors>true</MSBuildTreatWarningsAsErrors>
1112
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
13+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
1214
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1315
<NoWarn>$(NoWarn);CS1591;</NoWarn>
1416
</PropertyGroup>

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageVersion Include="Cocona" Version="2.2.0" />
8-
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
9-
<PackageVersion Include="Spectre.Console.Cli" Version="0.53.1" />
10-
<PackageVersion Include="System.CommandLine" Version="2.0.3" />
8+
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="5.1.0" />
9+
<PackageVersion Include="Spectre.Console.Cli" Version="0.55.0" />
10+
<PackageVersion Include="System.CommandLine" Version="2.0.7" />
1111
</ItemGroup>
1212
</Project>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Using various command line tools frameworks
1919
> - [App.exe] --help
2020
>
2121
22-
**`Tools`** : net 8.0
22+
**`Tools`** : net 10.0

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "10.0.200",
44
"rollForward": "latestMinor",
55
"allowPrerelease": false
66
}

src/SpectreConsoleCli/App01/Program.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Spectre.Console.Cli;
22
using System.ComponentModel;
3+
using Spectre.Console;
34

45
namespace App01;
56

@@ -11,11 +12,13 @@ public static int Main(string[] args)
1112

1213
app.Configure(config =>
1314
{
14-
config.AddCommand<UpperCommand>(Constants.UpperCommandName)
15+
config
16+
.AddCommand<UpperCommand>(Constants.UpperCommandName)
1517
.WithAlias(Constants.UpperCommandAlias)
1618
.WithDescription(Constants.UpperCommandDescription);
1719

18-
config.AddCommand<LowerCommand>(Constants.LowerCommandName)
20+
config
21+
.AddCommand<LowerCommand>(Constants.LowerCommandName)
1922
.WithAlias(Constants.LowerCommandAlias)
2023
.WithDescription(Constants.LowerCommandDescription);
2124
});
@@ -25,7 +28,7 @@ public static int Main(string[] args)
2528

2629
private class UpperCommand : Command<InputSetting>
2730
{
28-
public override int Execute(CommandContext context, InputSetting settings, CancellationToken cancellationToken)
31+
protected override int Execute(CommandContext context, InputSetting settings, CancellationToken cancellationToken)
2932
{
3033
Constants.Color.WriteLine($"Upper = '{settings.Input.ToUpper()}'");
3134
return 0;
@@ -34,7 +37,7 @@ public override int Execute(CommandContext context, InputSetting settings, Cance
3437

3538
private sealed class LowerCommand : Command<InputSetting>
3639
{
37-
public override int Execute(CommandContext context, InputSetting settings, CancellationToken cancellationToken)
40+
protected override int Execute(CommandContext context, InputSetting settings, CancellationToken cancellationToken)
3841
{
3942
Constants.Color.WriteLine($"Lower = '{settings.Input.ToLower()}'");
4043
return 0;
@@ -46,5 +49,12 @@ private sealed class InputSetting : CommandSettings
4649
[Description(Constants.InputOptionDescription)]
4750
[CommandOption("-i|--input <INPUT>")]
4851
public string Input { get; init; }
52+
53+
public override ValidationResult Validate()
54+
{
55+
return string.IsNullOrWhiteSpace(Input)
56+
? ValidationResult.Error("Input '-i|--input' is required.")
57+
: ValidationResult.Success();
58+
}
4959
}
5060
}

src/SystemCommandLine/App01/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static int Main(string[] args)
1717

1818
private static Command BuildUpperCommand()
1919
{
20-
var inputOption = new Option<string>("input", "i")
20+
var inputOption = new Option<string>("-i", "--input")
2121
{
2222
Required = true,
2323
Arity = ArgumentArity.ExactlyOne,
@@ -45,7 +45,7 @@ private static Command BuildUpperCommand()
4545

4646
private static Command BuildLowerCommand()
4747
{
48-
var inputOption = new Option<string>("input", "i")
48+
var inputOption = new Option<string>("-i", "--input")
4949
{
5050
Required = true,
5151
Arity = ArgumentArity.ExactlyOne,

0 commit comments

Comments
 (0)