MCPcopy Create free account
hub / github.com/apache/kvrocks / ParseCommandLineOptions

Function ParseCommandLineOptions

src/cli/main.cc:76–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76static CLIOptions ParseCommandLineOptions(int argc, char **argv) {
77 using namespace std::string_view_literals;
78 CLIOptions opts;
79
80 for (int i = 1; i < argc; ++i) {
81 if ((argv[i] == "-c"sv || argv[i] == "--config"sv) && i + 1 < argc) {
82 opts.conf_file = argv[++i];
83 } else if (argv[i] == "-v"sv || argv[i] == "--version"sv) {
84 std::cout << "kvrocks " << PrintVersion() << std::endl;
85 std::exit(0);
86 } else if (argv[i] == "-h"sv || argv[i] == "--help"sv) {
87 PrintUsage(*argv);
88 std::exit(0);
89 } else if (std::string_view(argv[i], 2) == "--" && std::string_view(argv[i]).size() > 2 && i + 1 < argc) {
90 auto key = std::string_view(argv[i] + 2);
91 opts.cli_options.emplace_back(key, argv[++i]);
92 } else {
93 PrintUsage(*argv, std::cerr);
94 std::exit(1);
95 }
96 }
97
98 return opts;
99}
100
101static Status InitSpdlog(const Config &config) {
102 std::vector<spdlog::sink_ptr> sinks;

Callers 1

mainFunction · 0.70

Calls 2

PrintVersionFunction · 0.85
PrintUsageFunction · 0.85

Tested by

no test coverage detected