proxygen
Main.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #include <fizz/tool/Commands.h>
10 #include <folly/ssl/Init.h>
11 #include <glog/logging.h>
12 
13 #include <iostream>
14 #include <string>
15 #include <vector>
16 
17 using namespace fizz::tool;
18 
19 void showUsage() {
20  std::cerr << "Supported commands:" << std::endl;
21  for (const auto& command : fizzUtilities) {
22  std::cerr << " - " << command.first << std::endl;
23  }
24  std::cerr << std::endl;
25 }
26 
27 int main(int argc, char** argv) {
28  google::InitGoogleLogging(argv[0]);
29  FLAGS_logtostderr = 1;
31  std::vector<std::string> arguments;
32  for (int i = 0; i < argc; i++) {
33  arguments.push_back(argv[i]);
34  }
35 
36  if (arguments.size() < 2) {
37  showUsage();
38  return 1;
39  } else {
40  if (fizzUtilities.count(arguments[1])) {
41  return fizzUtilities.at(arguments[1])(arguments);
42  } else {
43  std::cerr << "Unknown command '" << arguments[1] << "'." << std::endl;
44  showUsage();
45  return 1;
46  }
47  }
48  return 0;
49 }
void init()
Definition: Init.cpp:54
void showUsage()
Definition: Main.cpp:19
int main(int argc, char **argv)
Definition: Main.cpp:27
char ** argv
const std::map< std::string, std::function< int(const std::vector< std::string > &)> > fizzUtilities
Definition: Commands.h:23