blob: 1ba451a4274fd5bc3c7911e1b94a8182e7e9dde7 [file] [log] [blame]
Shinichiro Hamaji3c509d92015-09-08 13:34:51 +09001// 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 Hamaji171dc822015-10-08 16:40:21 +090021#include "strutil.h"
22
Shinichiro Hamaji3c509d92015-09-08 13:34:51 +090023int 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 Hamaji171dc822015-10-08 16:40:21 +090046
47 for (StringPiece tok : WordScanner(out)) {
48 printf("%.*s\n", SPF(tok));
49 }
Shinichiro Hamaji3c509d92015-09-08 13:34:51 +090050}