]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/rbd: introduce a new field of visible in Action Class
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Fri, 13 May 2016 08:47:22 +0000 (04:47 -0400)
committerDongsheng Yang <dongsheng.yang@easystack.cn>
Mon, 20 Jun 2016 05:24:44 +0000 (01:24 -0400)
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 <dongsheng.yang@easystack.cn>
src/tools/rbd/Shell.cc
src/tools/rbd/Shell.h

index 6e3431bed90813ed424f67f9502cc8b9d800580c..a08734d3b3926af8041cffa65a4715c371f2b29e 100644 (file)
@@ -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);
index 74378287471148ebf087c7585ddcb8d94c491364..682f95b554cd6095fc6f8d5d11122d15de07b51b 100644 (file)
@@ -28,15 +28,16 @@ public:
     const std::string help;
     GetArguments get_arguments;
     Execute execute;
+    bool visible;
 
     template <typename Args, typename Execute>
     Action(const std::initializer_list<std::string> &command_spec,
            const std::initializer_list<std::string> &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);
     }