From a287effde46968311ee5d973cb877ae8551c465d Mon Sep 17 00:00:00 2001 From: john30 Date: Thu, 4 Jun 2015 13:28:56 +0200 Subject: [PATCH] added option to exactly match name and circuit in find command --- ChangeLog.md | 1 + src/ebusd/mainloop.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 166f8a84..bcb4d2c6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,7 @@ ## Features * new "read" option "-n" for retrieving name/value pairs in numeric form +* new "find" option "-e" for exactly matching name and optional circuit (ignoring case) * added numeric and verbose options to JSON and use "null" for unset or replacement value * allow passing raw value when writing name/value pairs diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index c18aac22..0087c967 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -538,7 +538,7 @@ string MainLoop::executeWrite(vector &args) string MainLoop::executeFind(vector &args) { size_t argPos = 1; - bool verbose = false, configFormat = false, withRead = true, withWrite = false, withPassive = true, first = true, onlyWithData = false; + bool verbose = false, configFormat = false, exact = false, withRead = true, withWrite = false, withPassive = true, first = true, onlyWithData = false; string circuit; short pb = -1; while (args.size() > argPos && args[argPos][0] == '-') { @@ -546,6 +546,8 @@ string MainLoop::executeFind(vector &args) verbose = true; else if (args[argPos] == "-f") configFormat = true; + else if (args[argPos] == "-e") + exact = true; else if (args[argPos] == "-r") { if (first) { first = false; @@ -600,7 +602,7 @@ string MainLoop::executeFind(vector &args) argPos++; } if (argPos == 0 || args.size() < argPos || args.size() > argPos + 1) - return "usage: find [-v] [-r] [-w] [-p] [-d] [-i PB] [-f] [-c CIRCUIT] [NAME]\n" + return "usage: find [-v] [-r] [-w] [-p] [-d] [-i PB] [-f] [-e] [-c CIRCUIT] [NAME]\n" " Find message(s).\n" " -v be verbose (append destination address and update time)\n" " -r limit to active read messages (default: read + passive)\n" @@ -609,14 +611,15 @@ string MainLoop::executeFind(vector &args) " -d only include messages with actual data\n" " -i PB limit to messages with primary command byte PB ('0xPB' for hex)\n" " -f list messages in CSV configuration file format\n" - " -c CIRCUIT limit to messages of CIRCUIT (or a part thereof)\n" - " NAME the NAME of the messages to find (or a part thereof)"; + " -e match NAME and optional CIRCUIT exactly (ignoring case)\n" + " -c CIRCUIT limit to messages of CIRCUIT (or a part thereof without '-e')\n" + " NAME the NAME of the messages to find (or a part thereof without '-e')"; deque messages; if (args.size() == argPos) - messages = m_messages->findAll(circuit, "", pb, false, withRead, withWrite, withPassive); + messages = m_messages->findAll(circuit, "", pb, exact, withRead, withWrite, withPassive); else - messages = m_messages->findAll(circuit, args[argPos], pb, false, withRead, withWrite, withPassive); + messages = m_messages->findAll(circuit, args[argPos], pb, exact, withRead, withWrite, withPassive); bool found = false; ostringstream result;