code: def register_preloop_hook(self, func: Callable[[None], None]) -> None:
          
          self._validate_prepostloop_callable(func)
          self._preloop_hooks.append(func)
docs: Register a function to be called at the beginning of the command loop.