-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows.cpp
35 lines (32 loc) · 960 Bytes
/
windows.cpp
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
// Copyright 2025 Fred Emmott <fred@fredemmott.com>
// SPDX-License-Identifier: MIT
/* If you're not using the single-header version, you can
* include <magic_args/windows.hpp> instead of defining
* MAGIC_ARGS_ENABLE_WINDOWS_EXTENSIONS.
*
* This is off by default as depends on <Windows.h>
*/
#define MAGIC_ARGS_ENABLE_WINDOWS_EXTENSIONS
#include <magic_args/magic_args.hpp>
#include <thread>
struct MyArgs {
bool mFoo {false};
std::string mBar;
std::string mBaz;
};
int WINAPI wWinMain(
[[maybe_unused]] HINSTANCE hInstance,
[[maybe_unused]] HINSTANCE hPrevInstance,
[[maybe_unused]] LPWSTR lpCmdLine,
[[maybe_unused]] int nCmdShow) {
magic_args::attach_to_parent_terminal();
const auto args = magic_args::parse<MyArgs>(GetCommandLineW());
if (!args.has_value()) {
if (args.error() == magic_args::HelpRequested) {
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
magic_args::dump(*args);
return EXIT_SUCCESS;
}