-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cc
34 lines (33 loc) · 1.04 KB
/
Main.cc
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
#include "LinkSwitch.h"
#include <optional>
#include <cstdio>
int wmain(int argc, wchar_t** argv) {
std::optional<LinkSwitch> linkSwitch;
try {
switch (argc) {
case 2:
linkSwitch = LinkSwitch();
break;
case 3:
linkSwitch = LinkSwitch(argv[2]);
break;
default:
wprintf_s(L"Usage: %s <key|#> [profile]\n", argv[0]);
return -1;
}
if (argv[1][0] == L'#' && argv[1][1] == 0) {
std::vector<std::wstring> availableKeys = linkSwitch->GetAvailableKeys();
for (size_t i = 0; i < availableKeys.size() - 1; i++) {
fputws(availableKeys.at(i).data(), stdout);
fputwc(L'\n', stdout);
}
fputws(availableKeys.at(availableKeys.size() - 1).data(), stdout);
} else {
linkSwitch->SwitchTo(argv[1]);
}
} catch (const std::exception& e) {
puts(e.what());
return -1;
}
return 0;
}