Add ApplicationCommands

This commit is contained in:
2021-06-07 01:45:39 +02:00
parent bee5ac6f9e
commit 878d26653c
2 changed files with 154 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Akari.Prototype.Server.Services;
using Spectre.Console;
namespace Akari.Prototype.Server.Utils
{
public static class CliUtils
{
private const int LoginMaxTries = 3;
public static bool Login(IMasterKeyService masterKeyService, IAnsiConsole ansiConsole)
{
string password;
int tries = 0;
do
{
tries++;
ansiConsole.WriteLine();
password = ansiConsole.Prompt(
new TextPrompt<string>("Enter [green]master password[/]")
.PromptStyle("red")
.Secret()
);
ansiConsole.WriteLine();
} while (!masterKeyService.Login(password) && tries < LoginMaxTries);
return masterKeyService.IsLoggedIn;
}
}
}