Skip to content

Commit

Permalink
Renamed everything to avoid using Spectre.Console namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jakenuts committed Dec 31, 2023
1 parent db24f52 commit 46f6056
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
///
/// </summary>
public class HelloCommand : AsyncCommand<HelloCommand.Options>
{
private readonly IAnsiConsole _console;

private readonly IServiceProvider _serviceProvider;

/// <summary>
/// Creates a HelloCommand with access to services, the console and logging
/// </summary>
/// <param name="serviceProvider"></param>
/// <param name="console"></param>
/// <param name="log"></param>
public HelloCommand(IServiceProvider serviceProvider, IAnsiConsole console, ILogger<HelloCommand> log)
{
_serviceProvider = serviceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Spectre.Console.Extensions.Hosting\Spectre.Console.Extensions.Hosting.csproj" />
<ProjectReference Include="..\Community.Extensions.Spectre.Cli.Hosting\Community.Extensions.Spectre.Cli.Hosting.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<HelloCommand>("hello");
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"Spectre.Console.Extensions.Hosting.Sample": {
"Community.Extensions.Spectre.Cli.Hosting.Sample": {
"commandName": "Project",
"commandLineArgs": "You -p Sadie"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// A basic handler that writes the exception to the AnsiConsole.
/// </summary>
public static class BasicExceptionHandler
{
/// <summary>
/// Writes the exception to the AnsiConsole.
/// </summary>
/// <param name="e"></param>
public static void WriteException(Exception e)
{
if (e is CommandAppException cae)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<PackageId>Spectre.Console.Extensions.Hosting</PackageId>
<PackageId>Community.Extensions.Spectre.Cli.Hosting</PackageId>
<Version>1.0.0</Version>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Spectre.Console.Cli;


namespace Spectre.Console.Extensions.Hosting;
namespace Community.Extensions.Spectre.Cli.Hosting;

internal sealed class CustomTypeRegistrar : ITypeRegistrar
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Extends <see cref="IHostBuilder" /> with SpectreConsole commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<Copyright></Copyright>
<Authors></Authors>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/jakenuts/Spectre.Console.Extensions.Hosting</RepositoryUrl>
<RepositoryUrl>https://github.com/jakenuts/Community.Extensions.Spectre.Cli.Hosting</RepositoryUrl>
<!-- <PackageIcon>small-logo.png</PackageIcon> -->
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://github.com/jakenuts/Spectre.Console.Extensions.Hosting</PackageProjectUrl>
<PackageProjectUrl>https://github.com/jakenuts/Community.Extensions.Spectre.Cli.Hosting</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>https://github.com/jakenuts/Spectre.Console.Extensions.Hosting/releases</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/jakenuts/Community.Extensions.Spectre.Cli.Hosting/releases</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup Label="Source Link">
Expand Down

0 comments on commit 46f6056

Please sign in to comment.