From 67a916d19ca0ba49e3af3b21aeee3108da432ae4 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 24 Jan 2017 19:40:30 +0000 Subject: [PATCH] CLI: show usage when --help/-h passed. --- src/platform/climain.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/platform/climain.cpp b/src/platform/climain.cpp index 0f0c6b27..f41e2423 100644 --- a/src/platform/climain.cpp +++ b/src/platform/climain.cpp @@ -10,8 +10,8 @@ namespace SolveSpace { extern std::shared_ptr framebuffer; } -static void ShowUsage(const std::string &argv0) { - fprintf(stderr, "Usage: %s [filename...]", argv0.c_str()); +static void ShowUsage(const std::string &cmd) { + fprintf(stderr, "Usage: %s [filename...]", cmd.c_str()); //-----------------------------------------------------------------------------> 80 col */ fprintf(stderr, R"( When run, performs an action specified by on every . @@ -84,6 +84,13 @@ static void ShowUsage(const std::string &argv0) { static bool RunCommand(const std::vector args) { if(args.size() < 2) return false; + for(const std::string &arg : args) { + if(arg == "--help" || arg == "-h") { + ShowUsage(args[0]); + return true; + } + } + std::function runner; std::vector inputFiles;