docs: def chalresp(ctx, slot, key, totp, touch, force, generate):
      """
      Program a challenge-response credential.
  
      If KEY is not given, an interactive prompt will ask for it.
      """
      controller = ctx.obj['controller']
  
      if key:
          if generate:
              ctx.fail('Invalid options: --generate conflicts with KEY argument.')
          elif totp:
              key = parse_b32_key(key)
          else:
              key = parse_key(key)
      else:
          if force and not generate:
              ctx.fail('No secret key given. Please remove the --force flag, '
                       'set the KEY argument or set the --generate flag.')
          elif totp:
              while True:
                  key = click.prompt('Enter a secret key (base32)', err=True)
                  try:
                      key = parse_b32_key(key)
                      break
                  except Exception as e:
                      click.echo(e)
          else:
              if generate:
                  key = os.urandom(20)
                  click.echo('Using a randomly generated key: {}'.format(
                      b2a_hex(key).decode('ascii')))
              else:
                  key = click.prompt('Enter a secret key', err=True)
                  key = parse_key(key)
  
      cred_type = 'TOTP' if totp else 'challenge-response'
      force or click.confirm('Program a {} credential in slot {}?'
                             .format(cred_type, slot), abort=True, err=True)
      try:
          controller.program_chalresp(slot, key, touch)
      except YkpersError as e:
          _failed_to_write_msg(ctx, e)