From 46f605630e4c896c3c91570e334e962f94fec64a Mon Sep 17 00:00:00 2001 From: James White Date: Sun, 31 Dec 2023 11:44:28 -0800 Subject: [PATCH] Renamed everything to avoid using Spectre.Console namespace --- README.md | 2 +- .../Commands/HelloCommand.cs | 12 +++++++++- ...ensions.Spectre.Cli.Hosting.Sample.csproj} | 2 +- .../Program.cs | 10 +++++--- .../Properties/launchSettings.json | 2 +- .../appsettings.json | 0 ...munity.Extensions.Spectre.Cli.Hosting.sln} | 24 +++++++++---------- .../BasicExceptionHandler.cs | 12 ++++++++-- ...ity.Extensions.Spectre.Cli.Hosting.csproj} | 2 +- .../CustomTypeRegistrar.cs | 2 +- .../CustomTypeResolver.cs | 2 +- .../SpectreConsoleHostBuilderExtensions.cs | 3 ++- .../SpectreConsoleWorker.cs | 2 +- src/Directory.Build.props | 6 ++--- 14 files changed, 52 insertions(+), 29 deletions(-) rename src/{Spectre.Console.Extensions.Hosting.Sample => Community.Extensions.Spectre.Cli.Hosting.Sample}/Commands/HelloCommand.cs (83%) rename src/{Spectre.Console.Extensions.Hosting.Sample/Spectre.Console.Extensions.Hosting.Sample.csproj => Community.Extensions.Spectre.Cli.Hosting.Sample/Community.Extensions.Spectre.Cli.Hosting.Sample.csproj} (84%) rename src/{Spectre.Console.Extensions.Hosting.Sample => Community.Extensions.Spectre.Cli.Hosting.Sample}/Program.cs (70%) rename src/{Spectre.Console.Extensions.Hosting.Sample => Community.Extensions.Spectre.Cli.Hosting.Sample}/Properties/launchSettings.json (63%) rename src/{Spectre.Console.Extensions.Hosting.Sample => Community.Extensions.Spectre.Cli.Hosting.Sample}/appsettings.json (100%) rename src/{Spectre.Console.Extensions.Hosting.sln => Community.Extensions.Spectre.Cli.Hosting.sln} (56%) rename src/{Spectre.Console.Extensions.Hosting => Community.Extensions.Spectre.Cli.Hosting}/BasicExceptionHandler.cs (71%) rename src/{Spectre.Console.Extensions.Hosting/Spectre.Console.Extensions.Hosting.csproj => Community.Extensions.Spectre.Cli.Hosting/Community.Extensions.Spectre.Cli.Hosting.csproj} (87%) rename src/{Spectre.Console.Extensions.Hosting => Community.Extensions.Spectre.Cli.Hosting}/CustomTypeRegistrar.cs (98%) rename src/{Spectre.Console.Extensions.Hosting => Community.Extensions.Spectre.Cli.Hosting}/CustomTypeResolver.cs (96%) rename src/{Spectre.Console.Extensions.Hosting => Community.Extensions.Spectre.Cli.Hosting}/SpectreConsoleHostBuilderExtensions.cs (98%) rename src/{Spectre.Console.Extensions.Hosting => Community.Extensions.Spectre.Cli.Hosting}/SpectreConsoleWorker.cs (97%) diff --git a/README.md b/README.md index a67af99..9aed153 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# Spectre.Console.Extensions.Hosting +# Community.Extensions.Spectre.Cli.Hosting Extension methods and a bit of fancy footwork to host Spectre.Console.Cli in a HostApplicationBuilder diff --git a/src/Spectre.Console.Extensions.Hosting.Sample/Commands/HelloCommand.cs b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/Commands/HelloCommand.cs similarity index 83% rename from src/Spectre.Console.Extensions.Hosting.Sample/Commands/HelloCommand.cs rename to src/Community.Extensions.Spectre.Cli.Hosting.Sample/Commands/HelloCommand.cs index e09e178..fa532e1 100644 --- a/src/Spectre.Console.Extensions.Hosting.Sample/Commands/HelloCommand.cs +++ b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/Commands/HelloCommand.cs @@ -2,16 +2,26 @@ using System.ComponentModel.DataAnnotations; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Spectre.Console; using Spectre.Console.Cli; -namespace Spectre.Console.Extensions.Hosting.Sample.Commands; +namespace Community.Extensions.Spectre.Cli.Hosting.Sample.Commands; +/// +/// +/// public class HelloCommand : AsyncCommand { private readonly IAnsiConsole _console; private readonly IServiceProvider _serviceProvider; + /// + /// Creates a HelloCommand with access to services, the console and logging + /// + /// + /// + /// public HelloCommand(IServiceProvider serviceProvider, IAnsiConsole console, ILogger log) { _serviceProvider = serviceProvider; diff --git a/src/Spectre.Console.Extensions.Hosting.Sample/Spectre.Console.Extensions.Hosting.Sample.csproj b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/Community.Extensions.Spectre.Cli.Hosting.Sample.csproj similarity index 84% rename from src/Spectre.Console.Extensions.Hosting.Sample/Spectre.Console.Extensions.Hosting.Sample.csproj rename to src/Community.Extensions.Spectre.Cli.Hosting.Sample/Community.Extensions.Spectre.Cli.Hosting.Sample.csproj index b3ddc7a..3f40b6a 100644 --- a/src/Spectre.Console.Extensions.Hosting.Sample/Spectre.Console.Extensions.Hosting.Sample.csproj +++ b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/Community.Extensions.Spectre.Cli.Hosting.Sample.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/Spectre.Console.Extensions.Hosting.Sample/Program.cs b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/Program.cs similarity index 70% rename from src/Spectre.Console.Extensions.Hosting.Sample/Program.cs rename to src/Community.Extensions.Spectre.Cli.Hosting.Sample/Program.cs index 7f83541..ee4752e 100644 --- a/src/Spectre.Console.Extensions.Hosting.Sample/Program.cs +++ b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/Program.cs @@ -3,8 +3,8 @@ using Microsoft.Extensions.Logging; using Spectre.Console; using Spectre.Console.Cli; -using Spectre.Console.Extensions.Hosting; -using Spectre.Console.Extensions.Hosting.Sample.Commands; +using Community.Extensions.Spectre.Cli.Hosting; +using Community.Extensions.Spectre.Cli.Hosting.Sample.Commands; var builder = Host.CreateApplicationBuilder(args); builder.Logging.AddSimpleConsole(); @@ -22,7 +22,11 @@ config.SetApplicationName("hello"); config.SetExceptionHandler(BasicExceptionHandler.WriteException); - // This configures the command with the internal service provider + // This configures the command with the internal service provider. + // Unfortunately, it comes after the external service provider & host have + // already been built. In future configuration should be extracted to a builder + // that can be configured prior to service provider creation allowing the two + // AddCommand calls to be combined. config.AddCommand("hello"); }); diff --git a/src/Spectre.Console.Extensions.Hosting.Sample/Properties/launchSettings.json b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/Properties/launchSettings.json similarity index 63% rename from src/Spectre.Console.Extensions.Hosting.Sample/Properties/launchSettings.json rename to src/Community.Extensions.Spectre.Cli.Hosting.Sample/Properties/launchSettings.json index 5330e57..a8897fe 100644 --- a/src/Spectre.Console.Extensions.Hosting.Sample/Properties/launchSettings.json +++ b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/Properties/launchSettings.json @@ -1,6 +1,6 @@ { "profiles": { - "Spectre.Console.Extensions.Hosting.Sample": { + "Community.Extensions.Spectre.Cli.Hosting.Sample": { "commandName": "Project", "commandLineArgs": "You -p Sadie" } diff --git a/src/Spectre.Console.Extensions.Hosting.Sample/appsettings.json b/src/Community.Extensions.Spectre.Cli.Hosting.Sample/appsettings.json similarity index 100% rename from src/Spectre.Console.Extensions.Hosting.Sample/appsettings.json rename to src/Community.Extensions.Spectre.Cli.Hosting.Sample/appsettings.json diff --git a/src/Spectre.Console.Extensions.Hosting.sln b/src/Community.Extensions.Spectre.Cli.Hosting.sln similarity index 56% rename from src/Spectre.Console.Extensions.Hosting.sln rename to src/Community.Extensions.Spectre.Cli.Hosting.sln index b93e342..c80e158 100644 --- a/src/Spectre.Console.Extensions.Hosting.sln +++ b/src/Community.Extensions.Spectre.Cli.Hosting.sln @@ -3,10 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34321.82 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spectre.Console.Extensions.Hosting", "Spectre.Console.Extensions.Hosting\Spectre.Console.Extensions.Hosting.csproj", "{66D53786-D1FF-4BDF-AC92-E503047870FC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spectre.Console.Extensions.Hosting.Sample", "Spectre.Console.Extensions.Hosting.Sample\Spectre.Console.Extensions.Hosting.Sample.csproj", "{01F02172-3E54-4233-8EDB-50B15BBF5704}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8905AA16-D82A-4103-8534-147EDD27B7FA}" ProjectSection(SolutionItems) = preProject ..\.gitignore = ..\.gitignore @@ -18,20 +14,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\README.md = ..\README.md EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Community.Extensions.Spectre.Cli.Hosting", "Community.Extensions.Spectre.Cli.Hosting\Community.Extensions.Spectre.Cli.Hosting.csproj", "{FEAA3890-23E2-4CC7-B8C4-CC8894F0C8A9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Community.Extensions.Spectre.Cli.Hosting.Sample", "Community.Extensions.Spectre.Cli.Hosting.Sample\Community.Extensions.Spectre.Cli.Hosting.Sample.csproj", "{3F3789C4-AA17-499A-80AB-E1C2E4D928A0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {66D53786-D1FF-4BDF-AC92-E503047870FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66D53786-D1FF-4BDF-AC92-E503047870FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66D53786-D1FF-4BDF-AC92-E503047870FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66D53786-D1FF-4BDF-AC92-E503047870FC}.Release|Any CPU.Build.0 = Release|Any CPU - {01F02172-3E54-4233-8EDB-50B15BBF5704}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {01F02172-3E54-4233-8EDB-50B15BBF5704}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01F02172-3E54-4233-8EDB-50B15BBF5704}.Release|Any CPU.ActiveCfg = Release|Any CPU - {01F02172-3E54-4233-8EDB-50B15BBF5704}.Release|Any CPU.Build.0 = Release|Any CPU + {FEAA3890-23E2-4CC7-B8C4-CC8894F0C8A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FEAA3890-23E2-4CC7-B8C4-CC8894F0C8A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FEAA3890-23E2-4CC7-B8C4-CC8894F0C8A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FEAA3890-23E2-4CC7-B8C4-CC8894F0C8A9}.Release|Any CPU.Build.0 = Release|Any CPU + {3F3789C4-AA17-499A-80AB-E1C2E4D928A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F3789C4-AA17-499A-80AB-E1C2E4D928A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F3789C4-AA17-499A-80AB-E1C2E4D928A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F3789C4-AA17-499A-80AB-E1C2E4D928A0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Spectre.Console.Extensions.Hosting/BasicExceptionHandler.cs b/src/Community.Extensions.Spectre.Cli.Hosting/BasicExceptionHandler.cs similarity index 71% rename from src/Spectre.Console.Extensions.Hosting/BasicExceptionHandler.cs rename to src/Community.Extensions.Spectre.Cli.Hosting/BasicExceptionHandler.cs index 9e9c12b..4a368f9 100644 --- a/src/Spectre.Console.Extensions.Hosting/BasicExceptionHandler.cs +++ b/src/Community.Extensions.Spectre.Cli.Hosting/BasicExceptionHandler.cs @@ -1,9 +1,17 @@ -using Spectre.Console.Cli; +using Spectre.Console; +using Spectre.Console.Cli; -namespace Spectre.Console.Extensions.Hosting; +namespace Community.Extensions.Spectre.Cli.Hosting; +/// +/// A basic handler that writes the exception to the AnsiConsole. +/// public static class BasicExceptionHandler { + /// + /// Writes the exception to the AnsiConsole. + /// + /// public static void WriteException(Exception e) { if (e is CommandAppException cae) diff --git a/src/Spectre.Console.Extensions.Hosting/Spectre.Console.Extensions.Hosting.csproj b/src/Community.Extensions.Spectre.Cli.Hosting/Community.Extensions.Spectre.Cli.Hosting.csproj similarity index 87% rename from src/Spectre.Console.Extensions.Hosting/Spectre.Console.Extensions.Hosting.csproj rename to src/Community.Extensions.Spectre.Cli.Hosting/Community.Extensions.Spectre.Cli.Hosting.csproj index 6b8b3de..933d243 100644 --- a/src/Spectre.Console.Extensions.Hosting/Spectre.Console.Extensions.Hosting.csproj +++ b/src/Community.Extensions.Spectre.Cli.Hosting/Community.Extensions.Spectre.Cli.Hosting.csproj @@ -5,7 +5,7 @@ enable enable true - Spectre.Console.Extensions.Hosting + Community.Extensions.Spectre.Cli.Hosting 1.0.0 diff --git a/src/Spectre.Console.Extensions.Hosting/CustomTypeRegistrar.cs b/src/Community.Extensions.Spectre.Cli.Hosting/CustomTypeRegistrar.cs similarity index 98% rename from src/Spectre.Console.Extensions.Hosting/CustomTypeRegistrar.cs rename to src/Community.Extensions.Spectre.Cli.Hosting/CustomTypeRegistrar.cs index 061ef09..5160d53 100644 --- a/src/Spectre.Console.Extensions.Hosting/CustomTypeRegistrar.cs +++ b/src/Community.Extensions.Spectre.Cli.Hosting/CustomTypeRegistrar.cs @@ -3,7 +3,7 @@ using Spectre.Console.Cli; -namespace Spectre.Console.Extensions.Hosting; +namespace Community.Extensions.Spectre.Cli.Hosting; internal sealed class CustomTypeRegistrar : ITypeRegistrar { diff --git a/src/Spectre.Console.Extensions.Hosting/CustomTypeResolver.cs b/src/Community.Extensions.Spectre.Cli.Hosting/CustomTypeResolver.cs similarity index 96% rename from src/Spectre.Console.Extensions.Hosting/CustomTypeResolver.cs rename to src/Community.Extensions.Spectre.Cli.Hosting/CustomTypeResolver.cs index ebc1d20..b880a29 100644 --- a/src/Spectre.Console.Extensions.Hosting/CustomTypeResolver.cs +++ b/src/Community.Extensions.Spectre.Cli.Hosting/CustomTypeResolver.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using Spectre.Console.Cli; -namespace Spectre.Console.Extensions.Hosting; +namespace Community.Extensions.Spectre.Cli.Hosting; internal sealed class CustomTypeResolver : ITypeResolver, IDisposable { diff --git a/src/Spectre.Console.Extensions.Hosting/SpectreConsoleHostBuilderExtensions.cs b/src/Community.Extensions.Spectre.Cli.Hosting/SpectreConsoleHostBuilderExtensions.cs similarity index 98% rename from src/Spectre.Console.Extensions.Hosting/SpectreConsoleHostBuilderExtensions.cs rename to src/Community.Extensions.Spectre.Cli.Hosting/SpectreConsoleHostBuilderExtensions.cs index 0f1e606..ef05e2d 100644 --- a/src/Spectre.Console.Extensions.Hosting/SpectreConsoleHostBuilderExtensions.cs +++ b/src/Community.Extensions.Spectre.Cli.Hosting/SpectreConsoleHostBuilderExtensions.cs @@ -2,9 +2,10 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting.Internal; +using Spectre.Console; using Spectre.Console.Cli; -namespace Spectre.Console.Extensions.Hosting; +namespace Community.Extensions.Spectre.Cli.Hosting; /// /// Extends with SpectreConsole commands. diff --git a/src/Spectre.Console.Extensions.Hosting/SpectreConsoleWorker.cs b/src/Community.Extensions.Spectre.Cli.Hosting/SpectreConsoleWorker.cs similarity index 97% rename from src/Spectre.Console.Extensions.Hosting/SpectreConsoleWorker.cs rename to src/Community.Extensions.Spectre.Cli.Hosting/SpectreConsoleWorker.cs index 7da9660..02994d5 100644 --- a/src/Spectre.Console.Extensions.Hosting/SpectreConsoleWorker.cs +++ b/src/Community.Extensions.Spectre.Cli.Hosting/SpectreConsoleWorker.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using Spectre.Console.Cli; -namespace Spectre.Console.Extensions.Hosting; +namespace Community.Extensions.Spectre.Cli.Hosting; public class SpectreConsoleWorker : BackgroundService { diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 2e23a3c..90bf25d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -18,12 +18,12 @@ git - https://github.com/jakenuts/Spectre.Console.Extensions.Hosting + https://github.com/jakenuts/Community.Extensions.Spectre.Cli.Hosting False - https://github.com/jakenuts/Spectre.Console.Extensions.Hosting + https://github.com/jakenuts/Community.Extensions.Spectre.Cli.Hosting MIT - https://github.com/jakenuts/Spectre.Console.Extensions.Hosting/releases + https://github.com/jakenuts/Community.Extensions.Spectre.Cli.Hosting/releases