about summary refs log tree commit diff
path: root/BugMine.CLI/CLIClient.cs
blob: 1fb0f6b569ee4106de867347ee222280859593a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Text.Json;
using ArcaneLibs.Extensions;
using BugMine.Web.Classes;
using LibMatrix.Responses;
using LibMatrix.Services;

namespace BugMine.CLI;

public class CLIClient(ILogger<CLIClient> logger, BugMineClient client) : BackgroundService {
    private readonly ILogger<CLIClient> _logger = logger;

    protected override async Task ExecuteAsync(CancellationToken stoppingToken) {

        while (!stoppingToken.IsCancellationRequested) {
            Console.WriteLine("""
                              1) List all projects
                              2) Mass create projects
                              3) Destroy all projects
                              4) Get room count
                              5) Summarize all projects
                              6) Mass create regular rooms

                              L) Logout
                              Q) Quit
                              """);

            var input = Console.ReadKey();
            Console.WriteLine();
            switch (input.Key) {
                
                case ConsoleKey.L: {
                    File.Delete("auth.json");
                    await ExecuteAsync(stoppingToken);
                    return;
                }
                case ConsoleKey.Q: {
                    Environment.Exit(0);
                    return;
                }
            }
        }
    }
}