Skip to content

Commit

Permalink
Migrate to use Devlead.Console
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Jan 20, 2025
1 parent ad2b137 commit 7f0699c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 60 deletions.
1 change: 0 additions & 1 deletion src/Blobify.Tests/Blobify.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Verify.NUnit" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 1 addition & 9 deletions src/Blobify/Blobify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,9 @@
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Cake.Bridge.DependencyInjection" />
<PackageReference Include="Cake.Common" />
<PackageReference Include="Devlead.Console" />
<PackageReference Include="Microsoft.Extensions.Http" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="all" />
<PackageReference Include="Spectre.Console.Analyzer" PrivateAssets="all" />
<PackageReference Include="Spectre.Console.Cli.Extensions.DependencyInjection" />
<PackageReference Include="Spectre.Console.Cli" />
<PackageReference Include="Spectre.Console" />
<PackageReference Include="System.Linq.Async" />
<PackageReference Include="MimeTypes" PrivateAssets="all" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

<ItemGroup>
Expand Down
57 changes: 16 additions & 41 deletions src/Blobify/Program.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
using Microsoft.Extensions.Configuration.Memory;
using Microsoft.Extensions.Configuration;
using Spectre.Console.Cli.Extensions.DependencyInjection;
using Azure.Core;
using Azure.Core;
using Azure.Identity;
using Blobify.Services.Storage;

var serviceCollection = new ServiceCollection()
public partial class Program
{
static partial void AddServices(IServiceCollection services)
{
services
.AddCakeCore()
.AddLogging(configure =>
configure
.AddSimpleConsole(opts =>
{
opts.TimestampFormat = "yyyy-MM-dd HH:mm:ss ";
})
.AddConfiguration(
new ConfigurationBuilder()
.Add(new MemoryConfigurationSource
{
InitialData = new Dictionary<string, string?>
{
{ "LogLevel:System.Net.Http.HttpClient", "Warning" }
}
})
.Build()
))

.AddSingleton<AzureTokenService>(
async (tenantId, scope) =>
{
Expand All @@ -40,27 +24,18 @@
}
)
.AddSingleton<ArchiveCommand>()
.AddSingleton<TokenService>();

serviceCollection.AddHttpClient();
.AddSingleton<Blobify.Services.Storage.TokenService>();

using var registrar = new DependencyInjectionRegistrar(serviceCollection);
var app = new CommandApp(registrar);
services.AddHttpClient();
}

app.Configure(
config =>
// Configure commands
static partial void ConfigureApp(AppServiceConfig appServiceConfig)
{
config.UseAssemblyInformationalVersion();
config.SetApplicationName("blobify");
config.ValidateExamples();
appServiceConfig.SetApplicationName("blobify");

config.AddCommand<ArchiveCommand>("archive")
appServiceConfig.AddCommand<ArchiveCommand>("archive")
.WithDescription("Example Archive command.")
.WithExample(["archive", "inputpath", "storageaccountname"]);

config.SetExceptionHandler(
(ex, _) => AnsiConsole.WriteException(ex, ExceptionFormats.ShowLinks)
);
});

return await app.RunAsync(args);
}
}
10 changes: 1 addition & 9 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,15 @@
<PackageVersion Include="Cake.Common" Version="5.0.0" />
<PackageVersion Include="Cake.Testing" Version="5.0.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="Devlead.Console" Version="2025.1.20.30" />
<PackageVersion Include="Devlead.Testing.MockHttp" Version="2025.1.20.16" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="MimeTypes" Version="2.5.2" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="NUnit" Version="4.3.2" />
<PackageVersion Include="NUnit.Analyzers" Version="4.6.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="Spectre.Console" Version="0.49.1" />
<PackageVersion Include="Spectre.Console.Analyzer" Version="1.0.0" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.49.1" />
<PackageVersion Include="Spectre.Console.Cli.Extensions.DependencyInjection" Version="0.3.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Text.Json" Version="9.0.1" />
<PackageVersion Include="Verify.Http" Version="6.4.1" />
<PackageVersion Include="Verify.NUnit" Version="28.9.0" />
</ItemGroup>
Expand Down

0 comments on commit 7f0699c

Please sign in to comment.