Allow Users to change customized ldb tools' header in help printing

Summary: Closes https://github.com/facebook/rocksdb/pull/2018

Differential Revision: D4748448

Pulled By: siying

fbshipit-source-id: a54c2f9
main
Siying Dong 8 years ago committed by Facebook Github Bot
parent a2a883318b
commit 17866ecc3a
  1. 2
      include/rocksdb/ldb_tool.h
  2. 2
      include/rocksdb/utilities/ldb_cmd.h
  3. 9
      tools/ldb_tool.cc

@ -26,6 +26,8 @@ struct LDBOptions {
// Key formatter that converts a slice to a readable string.
// Default: Slice::ToString()
std::shared_ptr<SliceFormatter> key_formatter;
std::string print_help_header = "ldb - RocksDB Tool";
};
class LDBTool {

@ -239,7 +239,7 @@ class LDBCommand {
class LDBCommandRunner {
public:
static void PrintHelp(const char* exec_name);
static void PrintHelp(const LDBOptions& ldb_options, const char* exec_name);
static void RunCommand(
int argc, char** argv, Options options, const LDBOptions& ldb_options,

@ -12,10 +12,11 @@ namespace rocksdb {
LDBOptions::LDBOptions() {}
void LDBCommandRunner::PrintHelp(const char* exec_name) {
void LDBCommandRunner::PrintHelp(const LDBOptions& ldb_options,
const char* exec_name) {
std::string ret;
ret.append("ldb - LevelDB Tool");
ret.append(ldb_options.print_help_header);
ret.append("\n\n");
ret.append("commands MUST specify --" + LDBCommand::ARG_DB +
"=<full_path_to_db_directory> when necessary\n");
@ -91,7 +92,7 @@ void LDBCommandRunner::RunCommand(
int argc, char** argv, Options options, const LDBOptions& ldb_options,
const std::vector<ColumnFamilyDescriptor>* column_families) {
if (argc <= 2) {
PrintHelp(argv[0]);
PrintHelp(ldb_options, argv[0]);
exit(1);
}
@ -99,7 +100,7 @@ void LDBCommandRunner::RunCommand(
argc, argv, options, ldb_options, column_families);
if (cmdObj == nullptr) {
fprintf(stderr, "Unknown command\n");
PrintHelp(argv[0]);
PrintHelp(ldb_options, argv[0]);
exit(1);
}

Loading…
Cancel
Save