Template
30 lines
688 B
C++
30 lines
688 B
C++
#include <core-library/views/command-line-args-view.h>
|
|
|
|
#include <filesystem>
|
|
#include <print>
|
|
|
|
void print_help(std::filesystem::path application_path)
|
|
{
|
|
std::println("Usage: {}", application_path.stem().string());
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
core::command_line_args_view command_line_args_view{argc, argv};
|
|
|
|
char help_option_name[]{"--help"};
|
|
char* fallback_argv[]{argv[0], help_option_name};
|
|
|
|
if (std::ranges::empty(command_line_args_view))
|
|
command_line_args_view = core::command_line_args_view(2, fallback_argv);
|
|
|
|
for (auto&& arg : command_line_args_view)
|
|
{
|
|
arg.with("--help", [&] {
|
|
print_help(command_line_args_view.appliation_path());
|
|
});
|
|
}
|
|
|
|
return 0;
|
|
}
|