Skip to content

Commit 9fd7bba

Browse files
committed
* Remove Lingo entirely
* Upgrade RT libraries * Move Test1Cmd class to separate file * Add a test for subcommands that uses JSON comparison to test the whole result
1 parent e961fff commit 9fd7bba

File tree

12 files changed

+99
-2244
lines changed

12 files changed

+99
-2244
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ jobs:
4747
- name: "dotnet pack: ${{ env.VER_STR }}"
4848
run: dotnet pack Src/RT.CommandLine.csproj --configuration Release -p:InformationalVersion="${{env.VER_STR}}" -p:VersionPrefix=${{env.VER_NUM}} -p:VersionSuffix=${{env.VER_SUF}} -p:FileVersion=${{env.VER_NUM}} -p:AssemblyVersion=${{env.VER_NUM}} -o Publish
4949

50-
- name: "dotnet pack Lingo: ${{ env.VER_STR }}"
51-
run: dotnet pack SrcLingo/RT.CommandLine.Lingo.csproj --configuration Release -p:InformationalVersion="${{env.VER_STR}}" -p:VersionPrefix=${{env.VER_NUM}} -p:VersionSuffix=${{env.VER_SUF}} -p:FileVersion=${{env.VER_NUM}} -p:AssemblyVersion=${{env.VER_NUM}} -o Publish
52-
5350
- name: Push to NuGet
5451
run: dotnet nuget push Publish/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
5552

RT.CommandLine.sln

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ VisualStudioVersion = 17.8.34330.188
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RT.CommandLine", "Src\RT.CommandLine.csproj", "{DED68431-337E-439C-94E4-ACE2E5363178}"
66
EndProject
7-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RT.CommandLine.Lingo", "SrcLingo\RT.CommandLine.Lingo.csproj", "{DC6401A1-14F1-44E3-A121-43CC2F192809}"
8-
EndProject
97
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RT.CommandLine.Tests", "Tests\RT.CommandLine.Tests.csproj", "{294D2B02-3FA6-4B9A-82BF-F80396943892}"
108
EndProject
119
Global
@@ -18,10 +16,6 @@ Global
1816
{DED68431-337E-439C-94E4-ACE2E5363178}.Debug|Any CPU.Build.0 = Debug|Any CPU
1917
{DED68431-337E-439C-94E4-ACE2E5363178}.Release|Any CPU.ActiveCfg = Release|Any CPU
2018
{DED68431-337E-439C-94E4-ACE2E5363178}.Release|Any CPU.Build.0 = Release|Any CPU
21-
{DC6401A1-14F1-44E3-A121-43CC2F192809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22-
{DC6401A1-14F1-44E3-A121-43CC2F192809}.Debug|Any CPU.Build.0 = Debug|Any CPU
23-
{DC6401A1-14F1-44E3-A121-43CC2F192809}.Release|Any CPU.ActiveCfg = Release|Any CPU
24-
{DC6401A1-14F1-44E3-A121-43CC2F192809}.Release|Any CPU.Build.0 = Release|Any CPU
2519
{294D2B02-3FA6-4B9A-82BF-F80396943892}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2620
{294D2B02-3FA6-4B9A-82BF-F80396943892}.Debug|Any CPU.Build.0 = Debug|Any CPU
2721
{294D2B02-3FA6-4B9A-82BF-F80396943892}.Release|Any CPU.ActiveCfg = Release|Any CPU

Src/CommandLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Reflection;
1+
using System.Reflection;
22
using RT.Internal;
33
using RT.PostBuild;
44
using RT.Util;

Src/RT.CommandLine.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
19-
<PackageReference Include="RT.PostBuild" Version="2.0.1770" />
20-
<PackageReference Include="RT.Util.Core" Version="2.0.1770" />
19+
<PackageReference Include="RT.PostBuild" Version="2.0.1774" />
20+
<PackageReference Include="RT.Util.Core" Version="2.0.1774" />
2121
</ItemGroup>
2222

2323
<ItemGroup>

SrcLingo/CommandLine.cs

Lines changed: 0 additions & 2127 deletions
This file was deleted.

SrcLingo/RT.CommandLine.Lingo.csproj

Lines changed: 0 additions & 24 deletions
This file was deleted.

Tests/CommandLineLingoTests.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

Tests/CommandLineTests.cs

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using RT.Util.Consoles;
1+
using RT.Json;
2+
using RT.Serialization;
3+
using RT.Util.Consoles;
24
using Xunit;
35

46
namespace RT.CommandLine.Tests;
@@ -92,50 +94,6 @@ public static void TestInvalidOption()
9294
}
9395
}
9496

95-
96-
class Test1Cmd : ICommandLineValidatable
97-
{
98-
[IsPositional, IsMandatory]
99-
public string Base;
100-
101-
[IsPositional, IsMandatory]
102-
public Test1SubcommandBase Subcommand;
103-
104-
public static int ValidateCalled = 0;
105-
106-
public ConsoleColoredString Validate()
107-
{
108-
ValidateCalled++;
109-
return null;
110-
}
111-
}
112-
113-
[CommandGroup]
114-
abstract class Test1SubcommandBase : ICommandLineValidatable
115-
{
116-
public static int ValidateCalled = 0;
117-
public abstract ConsoleColoredString Validate();
118-
}
119-
120-
[CommandName("sub1")]
121-
sealed class Test1Subcommand1 : Test1SubcommandBase
122-
{
123-
[IsPositional, IsMandatory]
124-
public string ItemName;
125-
126-
public override ConsoleColoredString Validate()
127-
{
128-
ValidateCalled++;
129-
return null;
130-
}
131-
}
132-
133-
[CommandName("sub2")]
134-
sealed class Test1Subcommand2 : Test1SubcommandBase
135-
{
136-
public override ConsoleColoredString Validate() { return null; }
137-
}
138-
13997
[Fact]
14098
public static void TestSubcommandValidation()
14199
{
@@ -157,4 +115,16 @@ public static void TestSubcommandValidation()
157115
Assert.Equal(1, Test1Cmd.ValidateCalled);
158116
Assert.Equal(0, Test1SubcommandBase.ValidateCalled);
159117
}
118+
119+
[Fact]
120+
public static void TestMore()
121+
{
122+
Assert.True(
123+
JsonValue.Parse(@"{""Boolean"":true,""Subcommand"":{""SharedString"":null,""Name"":""this"","":type"":""Test2SubcommandAdd""}}")
124+
== ClassifyJson.Serialize(CommandLineParser.Parse<Test2Cmd>(["-b", "add", "this"])));
125+
126+
Assert.True(
127+
JsonValue.Parse(@"{""Boolean"":false,""Subcommand"":{""SharedString"":null,""Id"":""this"","":type"":""Test2SubcommandDelete""}}")
128+
== ClassifyJson.Serialize(CommandLineParser.Parse<Test2Cmd>(["del", "this"])));
129+
}
160130
}

Tests/RT.CommandLine.Tests.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
13-
<PackageReference Include="xunit" Version="2.9.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
13+
<PackageReference Include="RT.Serialization" Version="2.0.1774" />
14+
<PackageReference Include="RT.Serialization.Json" Version="2.0.1774" />
15+
<PackageReference Include="xunit" Version="2.9.1" />
1416
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1517
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1618
<PrivateAssets>all</PrivateAssets>
@@ -22,7 +24,6 @@
2224
</ItemGroup>
2325

2426
<ItemGroup>
25-
<ProjectReference Include="..\SrcLingo\RT.CommandLine.Lingo.csproj" />
2627
<ProjectReference Include="..\Src\RT.CommandLine.csproj" />
2728
</ItemGroup>
2829

0 commit comments

Comments
 (0)