Shinichiro Hamaji | 3c509d9 | 2015-09-08 13:34:51 +0900 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // +build ignore |
| 16 | |
| 17 | #include "find.h" |
| 18 | |
| 19 | #include <string> |
| 20 | |
Shinichiro Hamaji | 171dc82 | 2015-10-08 16:40:21 +0900 | [diff] [blame] | 21 | #include "strutil.h" |
| 22 | |
Shinichiro Hamaji | 3c509d9 | 2015-09-08 13:34:51 +0900 | [diff] [blame] | 23 | int main(int argc, char* argv[]) { |
| 24 | if (argc == 1) { |
| 25 | fprintf(stderr, "TODO: Write unit tests\n"); |
| 26 | return 1; |
| 27 | } |
| 28 | |
| 29 | InitFindEmulator(); |
| 30 | string cmd; |
| 31 | for (int i = 1; i < argc; i++) { |
| 32 | if (i > 1) |
| 33 | cmd += ' '; |
| 34 | cmd += argv[i]; |
| 35 | } |
| 36 | FindCommand fc; |
| 37 | if (!fc.Parse(cmd)) { |
| 38 | fprintf(stderr, "Find emulator does not support this command\n"); |
| 39 | return 1; |
| 40 | } |
| 41 | string out; |
| 42 | if (!FindEmulator::Get()->HandleFind(cmd, fc, &out)) { |
| 43 | fprintf(stderr, "Find emulator does not support this command\n"); |
| 44 | return 1; |
| 45 | } |
Shinichiro Hamaji | 171dc82 | 2015-10-08 16:40:21 +0900 | [diff] [blame] | 46 | |
| 47 | for (StringPiece tok : WordScanner(out)) { |
| 48 | printf("%.*s\n", SPF(tok)); |
| 49 | } |
Shinichiro Hamaji | 3c509d9 | 2015-09-08 13:34:51 +0900 | [diff] [blame] | 50 | } |