code: def do_prompt(
      text: str,
      default: str | None = None,
      validator: Callable[[str], Any] = nonempty,
  ) -> str | bool:
      while True:
          if default is not None:
              prompt = PROMPT_PREFIX + f"{text} [{default}]: "
          else:
              prompt = PROMPT_PREFIX + text + ": "
          if USE_LIBEDIT:
              # Note: libedit has a problem for combination of ``input()`` and escape
              # sequence (see #5335).  To avoid the problem, all prompts are not colored
              # on libedit.
              pass
          elif READLINE_AVAILABLE:
              # pass input_mode=True if readline available
              prompt = colorize(COLOR_QUESTION, prompt, input_mode=True)
          else:
              prompt = colorize(
                  COLOR_QUESTION, prompt, input_mode=False
              )
          x = term_input(prompt).strip()
          if default and not x:
              x = default
          try:
              x = validator(x)
          except ValidationError as err:
              print(red("* " + str(err)))
              continue
          break
      return x
  
imports: from __future__ import annotations
  import argparse
  import locale
  import os
  import sys
  import time
  from os import path
  from typing import TYPE_CHECKING, Any, Callable
  from docutils.utils import column_width
  import sphinx.locale
  from sphinx import __display_version__, package_dir
  from sphinx.locale import __
  from sphinx.util.console import bold, color_terminal, colorize, nocolor, red
  from sphinx.util.osutil import ensuredir
  from sphinx.util.template import SphinxRenderer
label_desc: Use image node_id 10 for calling a global function with example usage: do_prompt(text, default, validator) and returns: x