def prompt(text, default=None, hide_input=False, confirmation_prompt=False, type=None, value_proc=None, prompt_suffix=': ', show_default=True, err=False, show_choices=True):
 result = None
 def prompt_func(text):
  f = ((hide_input and hidden_prompt_func) or visible_prompt_func)
  try:
   echo(text, nl=False, err=err)
   return f('')
  except (KeyboardInterrupt, EOFError):
   if hide_input:
    echo(None, err=err)
   raise Abort()
 if (value_proc is None):
  value_proc = convert_type(type, default)
 prompt = _build_prompt(text, prompt_suffix, show_default, default, show_choices, type)
 while 1:
  while 1:
   value = prompt_func(prompt)
   if value:
    break
   elif (default is not None):
    return default
  try:
   result = value_proc(value)
  except UsageError as e:
   echo(('Error: %s' % e.message), err=err)
   continue
  if (not confirmation_prompt):
   return result
  while 1:
   value2 = prompt_func('Repeat for confirmation: ')
   if value2:
    break
  if (value == value2):
   return result
  echo('Error: the two entered values do not match', err=err)

def prompt ( text , default = None , hide_input = False , confirmation_prompt = False , type = None , value_proc = None , prompt_suffix = ': ' , show_default = True , err = False , show_choices = True ) : result = None def prompt_func ( text ) : f = ( ( hide_input and hidden_prompt_func ) or visible_prompt_func ) try : echo ( text , nl = False , err = err ) return f ( '' ) except ( KeyboardInterrupt , EOFError ) : if hide_input : echo ( None , err = err ) raise Abort ( ) if ( value_proc is None ) : value_proc = convert_type ( type , default ) prompt = _build_prompt ( text , prompt_suffix , show_default , default , show_choices , type ) while 1 : while 1 : value = prompt_func ( prompt ) if value : break elif ( default is not None ) : return default try : result = value_proc ( value ) except UsageError as e : echo ( ( 'Error: %s' % e . message ) , err = err ) continue if ( not confirmation_prompt ) : return result while 1 : value2 = prompt_func ( 'Repeat for confirmation: ' ) if value2 : break if ( value == value2 ) : return result echo ( 'Error: the two entered values do not match' , err = err )
presents the user with an input widget and returns the input .