Add ApplicationCommands
This commit is contained in:
37
Akari.Prototype.Server/Utils/CliUtils.cs
Normal file
37
Akari.Prototype.Server/Utils/CliUtils.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user