-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,40 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Configuration.Memory; | ||
using Microsoft.Extensions.Logging; | ||
using DPI.Commands.NuGet; | ||
using DPI.Commands.NuGet; | ||
using DPI.Commands.Settings.NuGet; | ||
using DPI.Models; | ||
using DPI.OutputConverters; | ||
using DPI.Parsers.NuGet; | ||
using Spectre.Console.Cli; | ||
using Spectre.Console.Cli.Extensions.DependencyInjection; | ||
|
||
var serviceCollection = new ServiceCollection() | ||
.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() | ||
)) | ||
.AddHttpClient() | ||
.AddTransient<NuGetAnalyzeSettings>() | ||
.AddTransient<NuGetReportSettings>() | ||
.AddSingleton<CsProjParser>() | ||
.AddSingleton<DotNetToolsManifestParser>() | ||
.AddSingleton<PackageConfigParser>() | ||
.AddSingleton<CakeParser>() | ||
.AddSingleton<NuGetParsers>() | ||
.AddSingleton<ProjectsAssetsParser>() | ||
.AddSingleton<IOutputConverter, JsonOutputConverter>() | ||
.AddSingleton<IOutputConverter, TableOutputConverter>() | ||
.AddSingleton<IOutputConverter, MarkdownOutputConverter>() | ||
.AddSingleton<ILookup<OutputFormat, IOutputConverter>, OutputConverterLookup>() | ||
.AddCakeCore(); | ||
|
||
using var registrar = new DependencyInjectionRegistrar(serviceCollection); | ||
var app = new CommandApp(registrar); | ||
public partial class Program | ||
{ | ||
static partial void AddServices(IServiceCollection services) | ||
{ | ||
services.AddHttpClient() | ||
.AddTransient<NuGetAnalyzeSettings>() | ||
.AddTransient<NuGetReportSettings>() | ||
.AddSingleton<CsProjParser>() | ||
.AddSingleton<DotNetToolsManifestParser>() | ||
.AddSingleton<PackageConfigParser>() | ||
.AddSingleton<CakeParser>() | ||
.AddSingleton<NuGetParsers>() | ||
.AddSingleton<ProjectsAssetsParser>() | ||
.AddSingleton<IOutputConverter, JsonOutputConverter>() | ||
.AddSingleton<IOutputConverter, TableOutputConverter>() | ||
.AddSingleton<IOutputConverter, MarkdownOutputConverter>() | ||
.AddSingleton<ILookup<OutputFormat, IOutputConverter>, OutputConverterLookup>() | ||
.AddCakeCore(); | ||
} | ||
|
||
app.Configure( | ||
config => | ||
static partial void ConfigureApp(AppServiceConfig appServiceConfig) | ||
{ | ||
config.UseAssemblyInformationalVersion(); | ||
config.SetApplicationName("dpi"); | ||
config.ValidateExamples(); | ||
config.AddBranch<NuGetSettings>("nuget", nuGet => { | ||
appServiceConfig.SetApplicationName("dpi"); | ||
appServiceConfig.AddBranch<NuGetSettings>("nuget", nuGet => { | ||
nuGet.SetDescription("NuGet dependency commands."); | ||
|
||
nuGet.AddCommand<NuGetAnalyzeCommand<NuGetAnalyzeSettings>>("analyze") | ||
.WithDescription("Inventories NuGet packages") | ||
.WithExample(new[] { "nuget", "<SourcePath>", "analyze" }); | ||
.WithExample(["nuget", "<SourcePath>", "analyze"]); | ||
|
||
nuGet.AddCommand<NuGetReportCommand>("report") | ||
.WithDescription("Inventories NuGet packages and reports to Azure Log Analytics") | ||
.WithExample(new[] { "nuget", "<SourcePath>", "report" }); | ||
.WithExample(["nuget", "<SourcePath>", "report"]); | ||
}); | ||
}); | ||
|
||
return await app.RunAsync(args); | ||
} | ||
} |