Files
2026-07-17 15:29:15 +02:00

36 lines
923 B
C++

#include <core-library/io/file-stream.h>
#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());
});
arg.with("--file=", [](std::filesystem::path file_path) {
const std::string file_content = core::file_stream::file_content_as_string(file_path);
std::println("{}", file_content);
});
}
return 0;
}