From aaa2bd1d7d93b57a8ea0353ac11b8e9a71458fd0 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 12 Jul 2016 15:55:47 +0200 Subject: [PATCH] Check for help in one place rather than every command --- renderdoccmd/renderdoccmd.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/renderdoccmd/renderdoccmd.cpp b/renderdoccmd/renderdoccmd.cpp index 193b72350..f5e9ab2ef 100644 --- a/renderdoccmd/renderdoccmd.cpp +++ b/renderdoccmd/renderdoccmd.cpp @@ -189,12 +189,6 @@ struct ThumbCommand : public Command virtual bool IsCaptureCommand() { return false; } virtual int Execute(cmdline::parser &parser, const CaptureOptions &) { - if(parser.exist("help")) - { - std::cerr << parser.usage() << std::endl; - return 0; - } - if(parser.rest().empty()) { std::cerr << "Error: thumb command requires a capture filename." << std::endl @@ -275,12 +269,6 @@ struct CaptureCommand : public Command virtual bool IsCaptureCommand() { return true; } virtual int Execute(cmdline::parser &parser, const CaptureOptions &opts) { - if(parser.exist("help")) - { - std::cerr << parser.usage() << std::endl; - return 0; - } - if(parser.rest().empty()) { std::cerr << "Error: capture command requires an executable to launch." << std::endl @@ -365,12 +353,6 @@ struct InjectCommand : public Command virtual bool IsCaptureCommand() { return true; } virtual int Execute(cmdline::parser &parser, const CaptureOptions &opts) { - if(parser.exist("help")) - { - std::cerr << parser.usage() << std::endl; - return 0; - } - uint32_t PID = parser.get("PID"); std::string workingDir = parser.get("working-dir"); std::string logFile = parser.get("capture-file"); @@ -527,6 +509,13 @@ int renderdoccmd(std::vector &argv) opts.DelayForDebugger = (uint32_t)cmd.get("opt-delay-for-debugger"); } + if(cmd.exist("help")) + { + std::cerr << cmd.usage() << std::endl; + clean_up(); + return 0; + } + int ret = it->second->Execute(cmd, opts); clean_up(); return ret;