From: Dongsheng Yang Date: Fri, 13 May 2016 08:47:22 +0000 (-0400) Subject: tools/rbd: introduce a new field of visible in Action Class X-Git-Tag: v11.0.0~90^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=367a5fe507fd80750727e9efd92c90e67967ae35;p=ceph.git tools/rbd: introduce a new field of visible in Action Class The new field means whether we want to show this Action in command help. Sometimes, we want to make one action to be deprecated and invisible to user, but we have to keep it working for compatibility. Then we need to support this action but make it invisible. Signed-off-by: Dongsheng Yang --- diff --git a/src/tools/rbd/Shell.cc b/src/tools/rbd/Shell.cc index 6e3431bed908..a08734d3b392 100644 --- a/src/tools/rbd/Shell.cc +++ b/src/tools/rbd/Shell.cc @@ -285,6 +285,8 @@ void Shell::print_help() { for (size_t i = 0; i < actions.size(); ++i) { Action *action = actions[i]; + if (!action->visible) + continue; std::stringstream ss; ss << indent << format_command_name(action->command_spec, action->alias_command_spec); diff --git a/src/tools/rbd/Shell.h b/src/tools/rbd/Shell.h index 743782874711..682f95b554cd 100644 --- a/src/tools/rbd/Shell.h +++ b/src/tools/rbd/Shell.h @@ -28,15 +28,16 @@ public: const std::string help; GetArguments get_arguments; Execute execute; + bool visible; template Action(const std::initializer_list &command_spec, const std::initializer_list &alias_command_spec, const std::string &description, const std::string &help, - Args args, Execute execute) + Args args, Execute execute, bool visible = true) : command_spec(command_spec), alias_command_spec(alias_command_spec), description(description), help(help), get_arguments(args), - execute(execute) { + execute(execute), visible(visible) { Shell::get_actions().push_back(this); }