refactor!: moved table services into a dedicated assembly

This commit is contained in:
Dylan R. E. Moonfire 2022-04-02 18:38:49 -05:00
parent bf9e40dadd
commit bb0dcd0d86
15 changed files with 218 additions and 137 deletions

View File

@ -4,3 +4,5 @@ flake.*
node_modules/
.direnv/
.config/
obj/
bin/

View File

@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4CE102F8
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MfGames.ToolBuilder.Tests", "tests\MfGames.ToolBuilder.Tests\MfGames.ToolBuilder.Tests.csproj", "{77DDD61F-AF57-4AE7-A2A8-08C61A630A9A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MfGames.ToolBuilder.Tables", "src\MfGames.ToolBuilder.Tables\MfGames.ToolBuilder.Tables.csproj", "{1124D139-7557-46C1-906A-39E939E6FFF9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -62,10 +64,23 @@ Global
{77DDD61F-AF57-4AE7-A2A8-08C61A630A9A}.Release|x64.Build.0 = Release|Any CPU
{77DDD61F-AF57-4AE7-A2A8-08C61A630A9A}.Release|x86.ActiveCfg = Release|Any CPU
{77DDD61F-AF57-4AE7-A2A8-08C61A630A9A}.Release|x86.Build.0 = Release|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Debug|x64.ActiveCfg = Debug|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Debug|x64.Build.0 = Debug|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Debug|x86.ActiveCfg = Debug|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Debug|x86.Build.0 = Debug|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Release|Any CPU.Build.0 = Release|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Release|x64.ActiveCfg = Release|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Release|x64.Build.0 = Release|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Release|x86.ActiveCfg = Release|Any CPU
{1124D139-7557-46C1-906A-39E939E6FFF9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5253E2A6-9565-45AF-92EA-1BFD3A63AC23} = {9C845D9A-B359-43B3-AE9E-B84CE945AF21}
{0A12108A-9E00-41E9-8935-F4AA7D6208FB} = {4CE102F8-5C70-4696-B85F-93BB10034918}
{77DDD61F-AF57-4AE7-A2A8-08C61A630A9A} = {4CE102F8-5C70-4696-B85F-93BB10034918}
{1124D139-7557-46C1-906A-39E939E6FFF9} = {9C845D9A-B359-43B3-AE9E-B84CE945AF21}
EndGlobalSection
EndGlobal

View File

@ -2,7 +2,27 @@
_An opinionated library for easily creating command-line tools in C#._
ToolBuilder is a library to encapsulate the setup and running of tools, CLI components arranged with verbs (like `git`). It includes some opinionated decisions on default setup.
MfGames.ToolBuilder is a library to encapsulate the setup and running of tools, CLI components arranged with verbs (like `git`). It includes some opinionated decisions on default setup.
## Building
To make sure the environment is correctly set up for build:
```sh
./scripts/setup.sh
```
To build the project:
```sh
./scripts/build.sh
```
To test the project:
```sh
./scripts/test.sh
```
## Commands

View File

@ -1,5 +0,0 @@
- [ ] Split out tables into an assembly
- [ ] Switch to GitVersion for release
- [ ] Switch to scripts instead of Node for targets
- [ ] Clean up the Gitlab setup
- [ ] Change configuration back to default

View File

@ -14,6 +14,10 @@ This builds the project and creates the binaries in debug mode.
This runs any required tests.
## `format.sh`
This is used to format the code base using our standards. It matches the commands in the `lefthook` pre-commit hook.
## `release.sh`
Intended to run in a CI environment, this creates a NuGet package and publishes it.

View File

@ -6,3 +6,9 @@ cd $(dirname $0)/..
# Format the .NET code
dotnet format || exit 1
# Format using Prettier.
prettier . --write --loglevel warn
# Format the Flake.
nixfmt flake.nix

View File

@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>Provides a tool service for creating tools that output tabular data to the console.</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0"/>
<PackageReference Include="ConsoleTableExt" Version="3.1.9"/>
<PackageReference Include="CsvHelper" Version="27.2.1"/>
<PackageReference Include="FluentResults" Version="3.3.0"/>
<PackageReference Include="Glob" Version="1.1.9"/>
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
<PackageReference Include="Roslynator.Analyzers" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="2.10.0"/>
<PackageReference Include="SerilogAnalyzer" Version="0.15.0"/>
<PackageReference Include="System.CommandLine" Version="[2.0.0-beta3.22114.1,)"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.ToolBuilder\MfGames.ToolBuilder.csproj"/>
</ItemGroup>
</Project>

View File

@ -1,14 +1,10 @@
#pragma warning disable Serilog004 // Constant MessageTemplate verifier
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.IO;
using System.Data;
using System.Globalization;
using System.IO;
using System.Linq;
using ConsoleTableExt;
@ -152,7 +148,7 @@ namespace MfGames.ToolBuilder.Tables
.Select(x => x.ColumnName)
.ToList();
List<string> expandedNames = tableColumns
var expandedNames = tableColumns
.SelectMany(x => IsMatch(allColumns, x))
.ToList();
@ -402,7 +398,7 @@ namespace MfGames.ToolBuilder.Tables
TableFormatType tableFormat)
{
// Build the table from options.
ConsoleTableBuilder builder = ConsoleTableBuilder.From(this.table);
var builder = ConsoleTableBuilder.From(this.table);
// Figure out formatting.
if (tableFormat == TableFormatType.Default)

View File

@ -48,7 +48,7 @@ namespace MfGames.ToolBuilder.Extensions
ICollection<string> possible)
{
// Look for a direct match.
List<string> found = possible
var found = possible
.Where(
x => string.Equals(
x,
@ -116,7 +116,7 @@ namespace MfGames.ToolBuilder.Extensions
}
// Attempt a fuzzy search.
List<string> possible = Enum.GetNames(typeof(TEnum))
var possible = Enum.GetNames(typeof(TEnum))
.Select(e => e.ToLower())
.Where(e => e.StartsWith(input.ToLower()))
.ToList();

View File

@ -36,6 +36,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MfGames.ToolBuilder.Tables\MfGames.ToolBuilder.Tables.csproj" />
<ProjectReference Include="..\..\src\MfGames.ToolBuilder\MfGames.ToolBuilder.csproj" />
</ItemGroup>

View File

@ -35,7 +35,9 @@ namespace MfGames.ToolBuilder.Tests
.WithArguments(
new[]
{
"run", "--project", projectFile.FullName, "--",
"run",
"--project", projectFile.FullName,
"--",
"crash",
})
.WithWorkingDirectory(projectFile.DirectoryName!)

View File

@ -10,6 +10,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MfGames.ToolBuilder.Tables\MfGames.ToolBuilder.Tables.csproj" />
<ProjectReference Include="..\..\src\MfGames.ToolBuilder\MfGames.ToolBuilder.csproj" />
</ItemGroup>