added option to exactly match name and circuit in find command

This commit is contained in:
john30
2015-06-04 13:28:56 +02:00
parent 22407e8734
commit a287effde4
2 changed files with 10 additions and 6 deletions
+1
View File
@@ -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
+9 -6
View File
@@ -538,7 +538,7 @@ string MainLoop::executeWrite(vector<string> &args)
string MainLoop::executeFind(vector<string> &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<string> &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<string> &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<string> &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<Message*> 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;