docs: def usb(
          ctx, enable, disable, list, enable_all, touch_eject, no_touch_eject,
          autoeject_timeout, chalresp_timeout, lock_code, force):
      """
      Enable or disable applications over USB.
      """
  
      def ensure_not_all_disabled(ctx, usb_enabled):
          for app in APPLICATION:
              if app & usb_enabled:
                  return
          ctx.fail('Can not disable all applications over USB.')
  
      if not (list or
              enable_all or
              enable or
              disable or
              touch_eject or
              no_touch_eject or
              autoeject_timeout or
              chalresp_timeout):
          ctx.fail('No configuration options chosen.')
  
      enable = APPLICATION.__members__.keys() if enable_all else enable
  
      _ensure_not_invalid_options(ctx, enable, disable)
  
      if touch_eject and no_touch_eject:
          ctx.fail('Invalid options.')
  
      dev = ctx.obj['dev']
  
      usb_supported = dev.config.usb_supported
      usb_enabled = dev.config.usb_enabled
      flags = dev.config.device_flags
  
      if not usb_supported:
          ctx.fail('USB interface not supported.')
  
      if list:
          _list_apps(ctx, usb_enabled)
  
      if touch_eject:
          flags |= FLAGS.MODE_FLAG_EJECT
      if no_touch_eject:
          flags &= ~FLAGS.MODE_FLAG_EJECT
  
      for app in enable:
          if APPLICATION[app] & usb_supported:
              usb_enabled |= APPLICATION[app]
          else:
              ctx.fail('{} not supported over USB.'.format(app))
      for app in disable:
          if APPLICATION[app] & usb_supported:
              usb_enabled &= ~APPLICATION[app]
          else:
              ctx.fail('{} not supported over USB.'.format(app))
  
      ensure_not_all_disabled(ctx, usb_enabled)
  
      f_confirm = '{}{}{}{}{}{}Configure USB interface?'.format(
          'Enable {}.\n'.format(
              ', '.join(
                  [str(APPLICATION[app]) for app in enable])) if enable else '',
          'Disable {}.\n'.format(
              ', '.join(
                  [str(APPLICATION[app]) for app in disable])) if disable else '',
          'Set touch eject.\n' if touch_eject else '',
          'Disable touch eject.\n' if no_touch_eject else '',
          'Set autoeject timeout to {}.\n'.format(
              autoeject_timeout) if autoeject_timeout else '',
          'Set challenge-response timeout to {}.\n'.format(
              chalresp_timeout) if chalresp_timeout else '')
  
      is_locked = dev.config.configuration_locked
  
      if force and is_locked and not lock_code:
          ctx.fail('Configuration is locked - please supply the --lock-code '
                   'option.')
      if lock_code and not is_locked:
          ctx.fail('Configuration is not locked - please remove the '
                   '--lock-code option.')
  
      force or click.confirm(f_confirm, abort=True, err=True)
  
      if is_locked and not lock_code:
          lock_code = prompt_lock_code()
  
      if lock_code:
          lock_code = _parse_lock_code(ctx, lock_code)
  
      try:
          dev.write_config(
              device_config(
                  usb_enabled=usb_enabled,
                  flags=flags,
                  auto_eject_timeout=autoeject_timeout,
                  chalresp_timeout=chalresp_timeout),
              reboot=True,
              lock_key=lock_code)
      except Exception as e:
          logger.error('Failed to write config', exc_info=e)
          ctx.fail('Failed to configure USB applications.')