code: def generate_hooked_command(cmd_name, cmd_cls, hooks):
      
  
      def run(self, orig_run=cmd_cls.run):
          self.run_command_hooks('pre_hooks')
          orig_run(self)
          self.run_command_hooks('post_hooks')
  
      return type(cmd_name, (cmd_cls, object),
                  {'run': run, 'run_command_hooks': run_command_hooks,
                   'pre_hooks': hooks.get('pre', []),
                   'post_hooks': hooks.get('post', [])})
docs: Returns a generated subclass of ``cmd_cls`` that runs the pre- and
      post-command hooks for that command before and after the ``cmd_cls.run``
      method.