code: async def apply_command(self, cmd):
          
          # FIXME: What are we guarding for here? We don't mention that None is
          # allowed as a value fo cmd.
          if cmd:
              if cmd.prehook:
                  await cmd.prehook(ui=self, dbm=self.dbman, cmd=cmd)
              try:
                  if asyncio.iscoroutinefunction(cmd.apply):
                      await cmd.apply(self)
                  else:
                      cmd.apply(self)
              except Exception as e:
                  self._error_handler(e)
              else:
                  if cmd.posthook:
                      logging.info('calling post-hook')
                      await cmd.posthook(ui=self, dbm=self.dbman, cmd=cmd)
docs: applies a command
  
          This calls the pre and post hooks attached to the command,
          as well as :meth:`cmd.apply`.
  
          :param cmd: an applicable command
          :type cmd: :class:`~alot.commands.Command`