protected def getCommand()

in kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cli/ControlCliArguments.scala [67:103]


  protected def getCommand(cliConfig: CliConfig): Command[_] = {
    cliConfig.action match {
      case ControlAction.CREATE => cliConfig.resource match {
          case ControlObject.BATCH => new CreateBatchCommand(cliConfig)
          case ControlObject.SERVER => new CreateServerCommand(cliConfig)
          case _ => throw new KyuubiException(s"Invalid resource: ${cliConfig.resource}")
        }
      case ControlAction.GET => cliConfig.resource match {
          case ControlObject.BATCH => new GetBatchCommand(cliConfig)
          case ControlObject.ENGINE => new GetEngineCommand(cliConfig)
          case ControlObject.SERVER => new GetServerCommand(cliConfig)
          case _ => throw new KyuubiException(s"Invalid resource: ${cliConfig.resource}")
        }
      case ControlAction.DELETE => cliConfig.resource match {
          case ControlObject.BATCH => new DeleteBatchCommand(cliConfig)
          case ControlObject.ENGINE => new DeleteEngineCommand(cliConfig)
          case ControlObject.SERVER => new DeleteServerCommand(cliConfig)
          case _ => throw new KyuubiException(s"Invalid resource: ${cliConfig.resource}")
        }
      case ControlAction.LIST => cliConfig.resource match {
          case ControlObject.BATCH => new ListBatchCommand(cliConfig)
          case ControlObject.ENGINE => new ListEngineCommand(cliConfig)
          case ControlObject.SERVER => new ListServerCommand(cliConfig)
          case ControlObject.SESSION => new ListSessionCommand(cliConfig)
          case _ => throw new KyuubiException(s"Invalid resource: ${cliConfig.resource}")
        }
      case ControlAction.LOG => cliConfig.resource match {
          case ControlObject.BATCH => new LogBatchCommand(cliConfig)
          case _ => throw new KyuubiException(s"Invalid resource: ${cliConfig.resource}")
        }
      case ControlAction.SUBMIT => cliConfig.resource match {
          case ControlObject.BATCH => new SubmitBatchCommand(cliConfig)
          case _ => throw new KyuubiException(s"Invalid resource: ${cliConfig.resource}")
        }
      case _ => throw new KyuubiException(s"Invalid operation: ${cliConfig.action}")
    }
  }