mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-27 18:52:18 +01:00
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using Spectre.Console;
|
|
|
|
namespace SnykRestApi.Services
|
|
{
|
|
public class OptionService : IHostedService
|
|
{
|
|
private readonly ILogger<OptionService> _logger;
|
|
private readonly AuditLogService _auditLogService;
|
|
|
|
public OptionService(ILogger<OptionService> logger, AuditLogService auditLogService)
|
|
{
|
|
_logger = logger;
|
|
_auditLogService = auditLogService;
|
|
}
|
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
var rule = new Rule("[yellow]Cloud Egineering Console App[/]");
|
|
AnsiConsole.Write(rule);
|
|
|
|
|
|
Console.WriteLine("-- This couldn't be done in the Snyk UI, so here we are.... ");
|
|
Console.WriteLine();
|
|
|
|
var choices = new[]
|
|
{
|
|
"Create Audit log CSV.",
|
|
"Exit"
|
|
};
|
|
var result = AnsiConsole.Prompt(new SelectionPrompt<string>()
|
|
.Title("Select what you want to do:")
|
|
.PageSize(10)
|
|
.MoreChoicesText("[grey](Move up and down to reveal more choices)[/]")
|
|
.AddChoices(choices));
|
|
|
|
if (result == choices[0])
|
|
{
|
|
await _auditLogService.CreateAuditLog();
|
|
}
|
|
//else if (result == choices[1])
|
|
//{
|
|
// // Do something
|
|
//}
|
|
|
|
rule = new Rule("[yellow]Done. Bye.[/]");
|
|
AnsiConsole.Write(rule);
|
|
}
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|