Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="5.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.9.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.12" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.10.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.13" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.0" />
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.1" />
<PackageVersion Include="coverlet.collector" Version="10.1.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing.XUnit" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Analyzer.Testing.XUnit" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeRefactoring.Testing.XUnit" Version="1.1.2" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.401" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.402" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.10.94" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.11.2" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.55.0" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.57.2" />
</ItemGroup>
</Project>
154 changes: 77 additions & 77 deletions src/Inshiminator.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -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<int> Main(string[] args)
{
var app = new CommandApp();
app.Configure(config =>
{
config.SetApplicationName("inshim");
config.AddCommand<AnalyzeCommand>("analyze")
.WithDescription("Analyze a project for hard dependencies")
.WithExample(new[] { "analyze", "MyProject.csproj" });
config.AddCommand<DoctorCommand>("doctor")
.WithDescription("Check system for Inshiminator compatibility");
});
return await app.RunAsync(args);
}
}
internal sealed class AnalyzeCommand : AsyncCommand<AnalyzeCommand.Settings>
{
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<int> 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<int> Main(string[] args)
{
var app = new CommandApp();
app.Configure(config =>
{
config.SetApplicationName("inshim");
config.AddCommand<AnalyzeCommand>("analyze")
.WithDescription("Analyze a project for hard dependencies")
.WithExample(new[] { "analyze", "MyProject.csproj" });

config.AddCommand<DoctorCommand>("doctor")
.WithDescription("Check system for Inshiminator compatibility");
});

return await app.RunAsync(args);
}
}

internal sealed class AnalyzeCommand : AsyncCommand<AnalyzeCommand.Settings>
{
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<int> 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;
}
}
Loading