|
|
|
@ -13,7 +13,7 @@ namespace ROCKSDB_NAMESPACE { |
|
|
|
|
LDBOptions::LDBOptions() {} |
|
|
|
|
|
|
|
|
|
void LDBCommandRunner::PrintHelp(const LDBOptions& ldb_options, |
|
|
|
|
const char* /*exec_name*/) { |
|
|
|
|
const char* /*exec_name*/, bool to_stderr) { |
|
|
|
|
std::string ret; |
|
|
|
|
|
|
|
|
|
ret.append(ldb_options.print_help_header); |
|
|
|
@ -99,22 +99,32 @@ void LDBCommandRunner::PrintHelp(const LDBOptions& ldb_options, |
|
|
|
|
WriteExternalSstFilesCommand::Help(ret); |
|
|
|
|
IngestExternalSstFilesCommand::Help(ret); |
|
|
|
|
|
|
|
|
|
fprintf(stderr, "%s\n", ret.c_str()); |
|
|
|
|
fprintf(to_stderr ? stderr : stdout, "%s\n", ret.c_str()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int LDBCommandRunner::RunCommand( |
|
|
|
|
int argc, char** argv, Options options, const LDBOptions& ldb_options, |
|
|
|
|
int argc, char const* const* argv, Options options, |
|
|
|
|
const LDBOptions& ldb_options, |
|
|
|
|
const std::vector<ColumnFamilyDescriptor>* column_families) { |
|
|
|
|
if (argc <= 2) { |
|
|
|
|
PrintHelp(ldb_options, argv[0]); |
|
|
|
|
return 1; |
|
|
|
|
if (std::string(argv[1]) == "--version") { |
|
|
|
|
printf("ldb from RocksDB %d.%d.%d\n", ROCKSDB_MAJOR, ROCKSDB_MINOR, |
|
|
|
|
ROCKSDB_PATCH); |
|
|
|
|
return 0; |
|
|
|
|
} else if (std::string(argv[1]) == "--help") { |
|
|
|
|
PrintHelp(ldb_options, argv[0], /*to_stderr*/ false); |
|
|
|
|
return 0; |
|
|
|
|
} else { |
|
|
|
|
PrintHelp(ldb_options, argv[0], /*to_stderr*/ true); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LDBCommand* cmdObj = LDBCommand::InitFromCmdLineArgs( |
|
|
|
|
argc, argv, options, ldb_options, column_families); |
|
|
|
|
if (cmdObj == nullptr) { |
|
|
|
|
fprintf(stderr, "Unknown command\n"); |
|
|
|
|
PrintHelp(ldb_options, argv[0]); |
|
|
|
|
PrintHelp(ldb_options, argv[0], /*to_stderr*/ true); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|