code: async def cli(ctx, endpoint, debug, websocket, post):
      
      lvl = logging.INFO
      if debug:
          lvl = logging.DEBUG
          click.echo("Setting debug level to %s" % debug)
      logging.basicConfig(level=lvl)
  
      if ctx.invoked_subcommand == "discover":
          ctx.obj = {"debug": debug}
          return
  
      if endpoint is None:
          err("Endpoint is required except when with 'discover'!")
          return
  
      protocol = None
      if post and websocket:
          err("You can force either --post or --websocket")
          return
      elif websocket:
          protocol = ProtocolType.WebSocket
      elif post:
          protocol = ProtocolType.XHRPost
  
      logging.debug("Using endpoint %s", endpoint)
      x = Device(endpoint, force_protocol=protocol, debug=debug)
      try:
          await x.get_supported_methods()
      except (requests.exceptions.ConnectionError, SongpalException) as ex:
          err("Unable to get supported methods: %s" % ex)
          sys.exit(-1)
      ctx.obj = x
docs: Songpal CLI.