lst_print_example.cc
1 // Copyright 2013, .com . All rights reserved.
2 // Author: Roman Gershman (romange@gmail.com)
3 //
4 #include <signal.h>
5 #include <sys/stat.h>
6 
7 #include <google/protobuf/compiler/importer.h>
8 #include <google/protobuf/dynamic_message.h>
9 #include <google/protobuf/text_format.h>
10 
11 #include "absl/strings/match.h"
12 
13 #include "base/init.h"
14 #include "file/list_file.h"
15 #include "strings/escaping.h"
16 #include "util/pprint/file_printer.h"
17 #include "util/pprint/pprint_utils.h"
18 
19 DECLARE_string(csv);
20 
21 DECLARE_bool(sizes);
22 DECLARE_bool(raw);
23 DECLARE_bool(count);
24 
25 using namespace util;
26 using std::string;
27 using util::Status;
28 
29 using std::cout;
30 
31 using namespace file;
32 
33 void sigpipe_handler(int signal) {
34  exit(1);
35 }
36 
37 int main(int argc, char** argv) {
38  MainInitGuard guard(&argc, &argv);
39 
40  signal(SIGPIPE, sigpipe_handler);
41 
42  size_t count = 0;
43 
44  // const Reflection* reflection = msg->GetReflection();
45  for (int i = 1; i < argc; ++i) {
46  StringPiece path(argv[i]);
47  LOG(INFO) << "Opening " << path;
48 
50  printer.Init(argv[i]);
51  auto st = printer.Run();
52  CHECK_STATUS(st);
53  count += printer.count();
54  }
55  if (FLAGS_count)
56  std::cout << "Count: " << count << std::endl;
57 
58  return 0;
59 }