-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (41 loc) · 1.69 KB
/
Program.cs
File metadata and controls
45 lines (41 loc) · 1.69 KB
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
44
45
using Dirigera.Lib;
using Dirigera.Lib.Extensions;
namespace Dirigera.Cli
{
internal class Program
{
static async Task Main(string[] args)
{
if (args.Length == 1)
{
var dirigera = await DirigeraManager.Discover(args[0]);
Console.WriteLine($"IpAddress: {dirigera.IpAddress}");
Console.WriteLine($"Authenticated?: {await dirigera.IsAuthenticated()}");
await dirigera.LoadAll();
Console.Write(dirigera.Hub?.ToJson());
}
else
{
Console.WriteLine("No auth token specified, press ENTER to start authentication...");
Console.ReadLine();
await AuthenticateAutomatically();
}
}
static async Task AuthenticateManually()
{
var hub = await DirigeraManager.Discover();
await hub.StartAuthentication();
Console.WriteLine("Press the Action-button on the DIRIGERA hub and then press ENTER...");
Console.ReadLine();
var authToken = await hub.FinishAuthentication();
Console.WriteLine($"Sucessfully authenticated with the DIRIGERA hub. The authentication token is: {authToken}");
}
static async Task AuthenticateAutomatically()
{
var hub = await DirigeraManager.Discover();
Console.WriteLine("Starting authentication process. Press the Action-button on the DIRIGERA hub now.");
var authToken = await hub.Authenticate();
Console.WriteLine($"Sucessfully authenticated with the DIRIGERA hub. The authentication token is: {authToken}");
}
}
}