diff --git a/slsDetectorSoftware/src/CmdParser.cpp b/slsDetectorSoftware/src/CmdParser.cpp index 90b548275..ab7dc52ad 100644 --- a/slsDetectorSoftware/src/CmdParser.cpp +++ b/slsDetectorSoftware/src/CmdParser.cpp @@ -25,9 +25,11 @@ void CmdParser::Parse(std::string s) { // taking s by value we can modify it. Reset(); - // Are we looking at -h --help? + // Are we looking at -h --help? avoid removing h from command starting + // with h when combined with detector id (ex, 1-hostname) bool h = replace_first(&s, "--help", " "); - h = h || replace_first(&s, "-h", " "); + h = h || replace_first(&s, " -h", " "); + h = h || replace_first(&s, "-h ", " "); help_ = h; // Extract the position indicies diff --git a/slsDetectorSoftware/tests/test-CmdParser.cpp b/slsDetectorSoftware/tests/test-CmdParser.cpp index 8c18401eb..d489a6e44 100644 --- a/slsDetectorSoftware/tests/test-CmdParser.cpp +++ b/slsDetectorSoftware/tests/test-CmdParser.cpp @@ -383,4 +383,14 @@ TEST_CASE("All stuff"){ REQUIRE(p.receiver_id()==2); REQUIRE(p.multi_id() == 3); REQUIRE(p.command() == "exptime"); +} + +TEST_CASE("Parse a command that has -h in it"){ + CmdParser p; + p.Parse("1-hostname somepc"); + REQUIRE(p.multi_id() == 1); + REQUIRE(p.command() == "hostname"); + REQUIRE(p.arguments().size() == 1); + REQUIRE(p.arguments()[0]== "somepc"); + } \ No newline at end of file