diff --git a/Directory.Packages.props b/Directory.Packages.props index 91d8d6c..06d8f96 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,20 +7,20 @@ - - + + - - + + - + - + diff --git a/src/Inshiminator.Cli/Program.cs b/src/Inshiminator.Cli/Program.cs index 804f15c..123e726 100644 --- a/src/Inshiminator.Cli/Program.cs +++ b/src/Inshiminator.Cli/Program.cs @@ -1,77 +1,77 @@ -using System; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Threading; -using System.Threading.Tasks; -using Spectre.Console; -using Spectre.Console.Cli; - -namespace Inshiminator.Cli; - -public static class Program -{ - public static async Task Main(string[] args) - { - var app = new CommandApp(); - app.Configure(config => - { - config.SetApplicationName("inshim"); - config.AddCommand("analyze") - .WithDescription("Analyze a project for hard dependencies") - .WithExample(new[] { "analyze", "MyProject.csproj" }); - - config.AddCommand("doctor") - .WithDescription("Check system for Inshiminator compatibility"); - }); - - return await app.RunAsync(args); - } -} - -internal sealed class AnalyzeCommand : AsyncCommand -{ - public sealed class Settings : CommandSettings - { - [Description("Path to the project or solution file")] - [CommandArgument(0, "[PROJECT]")] - public string? ProjectPath { get; init; } - - [Description("Generate a SARIF report")] - [CommandOption("-s|--sarif")] - public string? SarifPath { get; init; } - } - - protected override async Task ExecuteAsync([NotNull] CommandContext context, [NotNull] Settings settings, CancellationToken cancellationToken) - { - var path = settings.ProjectPath ?? "."; - AnsiConsole.MarkupLine($"[blue]Analyzing:[/] {path}"); - - await AnsiConsole.Status() - .StartAsync("Running analysis...", async ctx => - { - await Task.Delay(1000, cancellationToken); - }); - - AnsiConsole.MarkupLine("[green]Analysis complete![/]"); - AnsiConsole.Write(new Table() - .AddColumn("ID") - .AddColumn("Severity") - .AddColumn("Message") - .AddRow("INSHIM001", "[yellow]Warning[/]", "DateTime.UtcNow usage in OrderService.cs:45") - .AddRow("INSHIM002", "[yellow]Warning[/]", "Guid.NewGuid() usage in UserProfile.cs:12")); - - return 0; - } -} - -internal sealed class DoctorCommand : Command -{ - protected override int Execute([NotNull] CommandContext context, CancellationToken cancellationToken) - { - AnsiConsole.MarkupLine("[blue]Inshiminator Doctor[/]"); - AnsiConsole.MarkupLine(" .NET SDK: [green]Found[/]"); - AnsiConsole.MarkupLine(" Git: [green]Found[/]"); - AnsiConsole.MarkupLine(" Analyzers: [green]Loaded[/]"); - return 0; - } -} +using System; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.Threading; +using System.Threading.Tasks; +using Spectre.Console; +using Spectre.Console.Cli; + +namespace Inshiminator.Cli; + +public static class Program +{ + public static async Task Main(string[] args) + { + var app = new CommandApp(); + app.Configure(config => + { + config.SetApplicationName("inshim"); + config.AddCommand("analyze") + .WithDescription("Analyze a project for hard dependencies") + .WithExample(new[] { "analyze", "MyProject.csproj" }); + + config.AddCommand("doctor") + .WithDescription("Check system for Inshiminator compatibility"); + }); + + return await app.RunAsync(args); + } +} + +internal sealed class AnalyzeCommand : AsyncCommand +{ + public sealed class Settings : CommandSettings + { + [Description("Path to the project or solution file")] + [CommandArgument(0, "[PROJECT]")] + public string? ProjectPath { get; init; } + + [Description("Generate a SARIF report")] + [CommandOption("-s|--sarif")] + public string? SarifPath { get; init; } + } + + public override async Task ExecuteAsync([NotNull] CommandContext context, [NotNull] Settings settings, CancellationToken cancellationToken) + { + var path = settings.ProjectPath ?? "."; + AnsiConsole.MarkupLine($"[blue]Analyzing:[/] {path}"); + + await AnsiConsole.Status() + .StartAsync("Running analysis...", async ctx => + { + await Task.Delay(1000, cancellationToken); + }); + + AnsiConsole.MarkupLine("[green]Analysis complete![/]"); + AnsiConsole.Write(new Table() + .AddColumn("ID") + .AddColumn("Severity") + .AddColumn("Message") + .AddRow("INSHIM001", "[yellow]Warning[/]", "DateTime.UtcNow usage in OrderService.cs:45") + .AddRow("INSHIM002", "[yellow]Warning[/]", "Guid.NewGuid() usage in UserProfile.cs:12")); + + return 0; + } +} + +internal sealed class DoctorCommand : Command +{ + public override int Execute([NotNull] CommandContext context, CancellationToken cancellationToken) + { + AnsiConsole.MarkupLine("[blue]Inshiminator Doctor[/]"); + AnsiConsole.MarkupLine(" .NET SDK: [green]Found[/]"); + AnsiConsole.MarkupLine(" Git: [green]Found[/]"); + AnsiConsole.MarkupLine(" Analyzers: [green]Loaded[/]"); + return 0; + } +}