diff options
Diffstat (limited to 'markdown.cpp')
-rw-r--r-- | markdown.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/markdown.cpp b/markdown.cpp index fa14396..63f293d 100644 --- a/markdown.cpp +++ b/markdown.cpp @@ -1,3 +1,5 @@ +#include <unistd.h> + #include <fstream> #include <iostream> #include <iterator> @@ -11,6 +13,7 @@ #include <imgui_impl_opengl3.h> #include <imgui_md.h> +std::string g_base_address; ImFont * g_font_regular; ImFont * g_font_bold; ImFont * g_font_bold_large; @@ -56,12 +59,28 @@ static void resized(GLFWwindow *, int width, int height) static void print_usage(const char * program) { - std::cerr << "Usage: " << program << " FILE" << std::endl; + std::cerr << "Usage: " << program << " [-b BASE_ADDRESS] FILE" << std::endl; } int main(int argc, char ** argv) { - if (2 != argc) + int opt; + + while (-1 != (opt = getopt(argc, argv, "b:"))) + { + switch (opt) + { + case 'b': + g_base_address = optarg; + break; + case '?': + default: + print_usage(argv[0]); + return 2; + } + } + + if (optind >= argc) { print_usage(argv[0]); return 2; @@ -100,7 +119,7 @@ int main(int argc, char ** argv) ImGui_ImplOpenGL3_Init(glsl_version); std::ifstream in; - in.open(argv[1]); + in.open(argv[optind]); std::string text(std::istreambuf_iterator<char>(in), {}); in.close(); |