Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
heapwolf committed Nov 26, 2017
1 parent 6ace837 commit 07d0869
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Find string in keys or values using a regex
>in values <regex>
```

![img](/man/find.png)

Set the start of the current range
```bash
>start <string>
Expand Down
14 changes: 14 additions & 0 deletions lib/commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down
Binary file added man/find.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 07d0869

Please sign in to comment.