From 17866ecc3a8f086058f2e03b16c6fab10e6c853b Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Tue, 21 Mar 2017 17:22:10 -0700 Subject: [PATCH] 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 --- include/rocksdb/ldb_tool.h | 2 ++ include/rocksdb/utilities/ldb_cmd.h | 2 +- tools/ldb_tool.cc | 9 +++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/rocksdb/ldb_tool.h b/include/rocksdb/ldb_tool.h index 8a6918ba4..efe450b59 100644 --- a/include/rocksdb/ldb_tool.h +++ b/include/rocksdb/ldb_tool.h @@ -26,6 +26,8 @@ struct LDBOptions { // Key formatter that converts a slice to a readable string. // Default: Slice::ToString() std::shared_ptr key_formatter; + + std::string print_help_header = "ldb - RocksDB Tool"; }; class LDBTool { diff --git a/include/rocksdb/utilities/ldb_cmd.h b/include/rocksdb/utilities/ldb_cmd.h index 7df0cd76f..aad5a5617 100644 --- a/include/rocksdb/utilities/ldb_cmd.h +++ b/include/rocksdb/utilities/ldb_cmd.h @@ -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, diff --git a/tools/ldb_tool.cc b/tools/ldb_tool.cc index 8a138a0eb..5ecdd90a4 100644 --- a/tools/ldb_tool.cc +++ b/tools/ldb_tool.cc @@ -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 + "= when necessary\n"); @@ -91,7 +92,7 @@ void LDBCommandRunner::RunCommand( int argc, char** argv, Options options, const LDBOptions& ldb_options, const std::vector* 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); }