diff --git a/README.md b/README.md index d96922d..6e415e3 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,8 @@ Find string in keys or values using a regex >in values ``` +![img](/man/find.png) + Set the start of the current range ```bash >start diff --git a/lib/commands.cc b/lib/commands.cc index 4e9b94c..2a06731 100644 --- a/lib/commands.cc +++ b/lib/commands.cc @@ -62,6 +62,8 @@ void ldb::find(string exp, int type) { cout << "\r\n"; regex e(exp); + int hits = 0; + leveldb::Iterator* itr = db->NewIterator(leveldb::ReadOptions()); for (itr->Seek(key_start); itr->Valid(); itr->Next()) { @@ -80,6 +82,7 @@ void ldb::find(string exp, int type) { regex_search(subject, m, e); if (m.length()) { + hits++; string s = subject.substr(m.position(), m.length()); replace(subject, s, hi_start + s + hi_end); @@ -103,6 +106,17 @@ void ldb::find(string exp, int type) { } } + cout + << endl + << "[" + << "Found " + << COLOR_BLUE + << hits + << COLOR_NONE + << " occurrences" + << "]" + << endl; + cout << "\r\n"; delete itr; } diff --git a/man/find.png b/man/find.png new file mode 100644 index 0000000..b81830f Binary files /dev/null and b/man/find.png differ