You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2021/07/18 10:45:44 UTC

[GitHub] [incubator-kyuubi] timothy65535 opened a new pull request #826: [KYUUBI 825] Introduce jcommander framework to kyuubi project

timothy65535 opened a new pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826


   <!--
   Thanks for sending a pull request!
   
   Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
     2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
   -->
   
   ### _Why are the changes needed?_
   
   For more details, please go to #775 
   
   
   Hi @yaooqinn @pan3793, 
   
   Here's the patch base on JCommander in scala, please point out if the scala grammar is not used correctly.
   
   The following usage is generated from JCommander, I think it seems a bit long for users, we can discuss it here.
   By the way, we can use the format of bookkeeper-ctl‘s usage.
   
   Thanks.
   ```
   Usage: kyuubi-ctl <server|engine> <create|get|delete|list> [options]
   [ ENGINE ]
   get
     -s, --host       Hostname or IP address of a service.
     -u, --user       The user name this engine belong to.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -p, --port       Listening port of a service.
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -h, --help       
   delete
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -p, --port       Listening port of a service.
     -s, --host       Hostname or IP address of a service.
     -u, --user       The user name this engine belong to.
     -h, --help       
   list
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -p, --port       Listening port of a service.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -u, --user       The user name this engine belong to.
     -s, --host       Hostname or IP address of a service.
     -h, --help       
   
   [ SERVER ]
   create
     -s, --host       Hostname or IP address of a service.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -p, --port       Listening port of a service.
     -h, --help       
   get
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -h, --help       
   delete
     -s, --host       Hostname or IP address of a service.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -p, --port       Listening port of a service.
     -h, --help       
   list
     -p, --port       Listening port of a service.
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -s, --host       Hostname or IP address of a service.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -h, --help  
   ```
   
   
   ### BooKKeeper CTL Usage
   
   #### 1. Totoal Usage
   ```
   [bookkeeper-all-4.13.0]$ bin/bkctl
   bkctl interacts and operates Apache BookKeeper clusters
   
   Usage:  bkctl [flags] [command group] [commands]
   
       cookie              Commands on operating cookies
   
   Infrastructure commands :
   
       autorecovery        Command on some specific operation.
       bookie              Commands on operating a single bookie
       bookieid            Commands operating on bookie ids
       bookies             Commands on operating a cluster of bookies
       cluster             Commands on administrating bookkeeper clusters
   ```
   
   #### 2. When choose one command
   ````
   [bookkeeper-all-4.13.0]$ bin/bkctl bookie
   Commands on operating a single bookie
   
   Usage:  bkctl bookie [command] [command options]
   
   Commands:
   
       converttodbstorage                              Convert bookie indexes from
                                                       InterleavedStorage to DbLedgerStorage format
       converttointerleavedstorage                     Convert bookie indexes from
                                                       DbLedgerStorage to InterleavedStorage
                                                       format
       endpointinfo                                    Get all end point
                                                       information about a given bookie.
       flip-bookie-id                                  Update bookie id in ledgers
                                                       (this may take a long time).
       format                                          Format the current server
   
   ````
   
   
   
   
   
   ### _How was this patch tested?_
   - [X] Add some test cases that check the changes thoroughly including negative and positive cases if possible
   
   - [ ] Add screenshots for manual tests if appropriate
   
   - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/tools/testing.html#running-tests) locally before make a pull request
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r679352627



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import java.util.{NoSuchElementException, StringJoiner}
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, MissingCommandException, ParameterException}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.commands.common._
+import org.apache.kyuubi.ctl.commands.common.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.config.ConfigCommandGroup
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = Map(
+    ServiceType.engine -> new EngineCommandGroup,
+    ServiceType.server -> new ServerCommandGroup,
+    ServiceType.config -> new ConfigCommandGroup
+  )
+
+  def printAllCommandUsage(): Unit = {
+    // scalastyle:off println
+    val sj = new StringJoiner("|", "<", ">")
+    ServiceType.values.foreach(v => sj.add(String.valueOf(v)))
+    println(s"Usage: kyuubi-ctl ${sj.toString} [actions] [options] \n")
+    var prefixIndent = 0
+    for (st <- commands.keys) {
+      val prefix = "  " + String.valueOf(st)
+      if (prefix.length > prefixIndent) prefixIndent = prefix.length
+    }
+
+    for ((st, group) <- commands) {
+      val prefix = "  " + String.valueOf(st)
+      val info = prefix +
+        DefaultUsageFormatter.s(prefixIndent - prefix.length) + "  " +
+        group.desc()
+      println(info)
+    }
+
+    print(System.lineSeparator())
+    // scalastyle:off println
+  }
+
+  def printUsageOfJcommander(service: String, action: Option[String],
+      jcommander: JCommander): Unit = {
+    // scalastyle:off println
+    val act = if (action.isEmpty) "[actions]" else action
+    println(s"Usage: kyuubi-ctl ${service} ${act} [options]")
+    if (action.isEmpty) {
+      for (cmd <- jcommander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+    } else {
+      jcommander.setUsageFormatter(new UnixStyleUsage(jcommander))
+      jcommander.usage()
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException).cmd()
+
+    try {
+      serviceCommand.parse(args: _*)
+    } catch {
+      case t: MissingCommandException =>
+        printUsageOfJcommander(String.valueOf(service), Option.empty, serviceCommand)
+        return;
+      case t: ParameterException =>
+        val act = t.getJCommander.getParsedCommand
+        val commander = t.getJCommander.getCommands.get(act)
+        error(s"Parameter error for command: ${act}")
+        printUsageOfJcommander(String.valueOf(service), Option(act), commander)
+        return;
+    }
+
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[Command]).foreach(cmd => {
+      cmd.asInstanceOf[Command].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+    val shell = new KyuubiCli
+
+    if (args == null || args(0).equals("-h") || args(0).equals("--help") || args.length == 1) {
+      shell.printAllCommandUsage()
+    } else {
+      try {
+        shell.run(ServiceType.withName(args(0)), args.drop(1))
+      } catch {
+        case _: NoSuchElementException =>
+          error(s"unknown service type: args(0)")

Review comment:
       Good catch




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674456462



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/UnixStyleUsage.scala
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import java.lang.{StringBuilder => Builder}
+import java.util.List
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, ParameterDescription}
+
+class UnixStyleUsage(commander: JCommander) extends DefaultUsageFormatter(commander) {
+
+  override def appendMainLine(out: Builder, hasOptions: Boolean,
+                              hasCommands: Boolean, indentCount: Int, indent: String): Unit = {

Review comment:
       ```suggestion
             hasCommands: Boolean, indentCount: Int, indent: String): Unit = {
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (90b8ccf) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `30.00%`.
   
   > :exclamation: Current head 90b8ccf differs from pull request most recent head 9737563. Consider uploading reports for the commit 9737563 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5293     +170     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4078      +51     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...9737563](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r679339572



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/UnixStyleUsage.scala
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import java.lang.{StringBuilder => Builder}

Review comment:
       the scala StringBuilder is not compatible with java.lang.StringBuilder. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674457575



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/DeleteEngineCommand.scala
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("delete"))
+class DeleteEngineCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 2)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 3)
+  var port: String = _
+
+  @Parameter(
+    names = Array("-u", "--user"),
+    description = "The user name this engine belong to.",
+    order = 4)
+  var user: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 5)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO

Review comment:
       `TODO` means main logic will be put here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r679339572



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/UnixStyleUsage.scala
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import java.lang.{StringBuilder => Builder}

Review comment:
       The scala StringBuilder is not compatible with java.lang.StringBuilder. It affects the override method `appendAllParametersDetails`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672089792



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }
+
+  def usage(): Unit = {
+    // scalastyle:off println
+    println("Usage: kyuubi-ctl <server|engine> <create|get|delete|list> [options]")
+    for ((service, commander) <- commands) {
+      println(s"[ $service ]")
+      for (cmd <- commander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+      print(System.lineSeparator())
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException)
+
+    serviceCommand.parse(args: _*)
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[AbstractCommand]).foreach(cmd => {
+      cmd.asInstanceOf[AbstractCommand].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+
+    val shell = new KyuubiCli
+    if (args(0).equals("--help")) {

Review comment:
       this is hardcoded, uses shall get help whenever an error occurs or they request help explictly




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674459533



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/GetEngineCommand.scala
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+import com.google.common.annotations.VisibleForTesting
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("get"))
+class GetEngineCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 2)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 3)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 4)
+  var port: Int = _
+
+  @Parameter(
+    names = Array("-u", "--user"),
+    description = "The user name this engine belong to.",
+    order = 5)
+  var user: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 6)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO
+    }
+  }
+
+  @VisibleForTesting
+  def test(): (String, String, Int) = {

Review comment:
       These commands did not return value, so need this.
   
   https://github.com/apache/bookkeeper/tree/master/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/bookie




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (90b8ccf) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `30.00%`.
   
   > :exclamation: Current head 90b8ccf differs from pull request most recent head fbad4bd. Consider uploading reports for the commit fbad4bd to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5293     +170     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4078      +51     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...fbad4bd](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-889770977


   > maybe we can do it group by group
   
   Right, first step is introduce framework to kyuubi project, we can discuss the design of the command frammework.
   
   Next plan:
   - [ ] Implement engine part
   - [ ] Implement service part
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (45bc1f4) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `29.58%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5292     +169     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4077      +50     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...45bc1f4](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-889770977






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 closed pull request #826: [WIP] [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 closed pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882606297


   @yaooqinn would you please add some details or demos on `config`? in my view, the chosen will be based on the code reused rate.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674460755



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/GetEngineCommand.scala
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+import com.google.common.annotations.VisibleForTesting
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("get"))
+class GetEngineCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 2)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 3)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 4)
+  var port: Int = _
+
+  @Parameter(
+    names = Array("-u", "--user"),
+    description = "The user name this engine belong to.",
+    order = 5)
+  var user: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 6)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO
+    }
+  }
+
+  @VisibleForTesting
+  def test(): (String, String, Int) = {

Review comment:
       Got, done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3f5eb6e) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `30.00%`.
   
   > :exclamation: Current head 3f5eb6e differs from pull request most recent head fbad4bd. Consider uploading reports for the commit fbad4bd to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5293     +170     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4078      +51     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...fbad4bd](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674459331



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/GetEngineCommand.scala
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+import com.google.common.annotations.VisibleForTesting
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("get"))
+class GetEngineCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 2)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 3)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 4)
+  var port: Int = _
+
+  @Parameter(
+    names = Array("-u", "--user"),
+    description = "The user name this engine belong to.",
+    order = 5)
+  var user: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 6)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO
+    }
+  }
+
+  @VisibleForTesting
+  def test(): (String, String, Int) = {

Review comment:
       the attributes are public




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674457386



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/GetEngineCommand.scala
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+import com.google.common.annotations.VisibleForTesting
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("get"))
+class GetEngineCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 2)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 3)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 4)
+  var port: Int = _
+
+  @Parameter(
+    names = Array("-u", "--user"),
+    description = "The user name this engine belong to.",
+    order = 5)
+  var user: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 6)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO
+    }
+  }
+
+  @VisibleForTesting
+  def test(): (String, String, Int) = {

Review comment:
       is it necessary?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-889340797


   Hi @pan3793 @yaooqinn thanks for the suggestion, patch is updated accordingly, can you please take another look. BTW, sorry for the delay, there are a lot of things to deal with in the past week. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3f5eb6e) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `30.00%`.
   
   > :exclamation: Current head 3f5eb6e differs from pull request most recent head ba3c25e. Consider uploading reports for the commit ba3c25e to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5293     +170     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4078      +51     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...ba3c25e](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (08f2b4f) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `30.00%`.
   
   > :exclamation: Current head 08f2b4f differs from pull request most recent head fbad4bd. Consider uploading reports for the commit fbad4bd to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5293     +170     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4078      +51     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...fbad4bd](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674457985



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/server/CreateServerCommand.scala
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.server
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("create"))
+class CreateServerCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 2)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 3)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 4)
+  var port: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 5)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO

Review comment:
       the logic for the command will put here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882663137


   `kyuubi-ctl config [create|get|delete|list]` makes more sense to me, and I suggest change `create` to `set`, `delete` to `remove` for object `config`, in other words, we can use independent action words for different objects.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882618945


    - create, apply a config to a running server(maybe)or a configuration file
    - list, get and validate all configurations in the configuration file(can be configured with -f -type (spark|kyuubi))
    - get, get a single config's config entry with doc, version, key, value, etc
    - delete, unapply a config to a running server(maybe) or a configuration file
    
   or something.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884617534


   > Hi @yaooqinn @pan3793 @turboFei, review again when you are free , thanks.
   > 
   > ### cmd examples
   > 1. input `--help`
   > 
   > ```
   > Usage: kyuubi-ctl <server|engine|config> [actions] [options] 
   > 
   >   engine  Commands on operating engine
   >   server  Commands on operating server
   >   config  Commands on operating config
   > ```
   > 
   > 1. input `server --help`
   > 
   > ```
   > Usage: kyuubi-ctl server [actions] [options]
   > create
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > get
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > delete
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > list
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > ```
   > 
   > 1. input `server get --help`
   > 
   > ```
   > get
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using 
   >                      zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help 
   > ```
   > 
   > ### Easy to add new more service / command
   > 1. Add new command which extends `Command`
   > 2. Add the new command to service command group
   > 3. If add new service type, need to update `Kyuubi`
   > 4. ok
   > 
   > ![image](https://user-images.githubusercontent.com/86483005/126579899-83b2ef6f-dc22-43d4-baa4-fc7313bc01ce.png)
   
   the behavior changes a lot for each command, the acceptable args change from cmd to cmd. I can remember each very well, but the create server logic seems to be wrong according to the help instructions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r675151661



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import java.util.{NoSuchElementException, StringJoiner}
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, MissingCommandException, ParameterException}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.commands.common._
+import org.apache.kyuubi.ctl.commands.common.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.config.ConfigCommandGroup
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = Map(
+    ServiceType.engine -> new EngineCommandGroup,
+    ServiceType.server -> new ServerCommandGroup,
+    ServiceType.config -> new ConfigCommandGroup
+  )
+
+  def printAllCommandUsage(): Unit = {
+    // scalastyle:off println
+    val sj = new StringJoiner("|", "<", ">")
+    ServiceType.values.foreach(v => sj.add(String.valueOf(v)))
+    println(s"Usage: kyuubi-ctl ${sj.toString} [actions] [options] \n")
+    var prefixIndent = 0
+    for (st <- commands.keys) {
+      val prefix = "  " + String.valueOf(st)
+      if (prefix.length > prefixIndent) prefixIndent = prefix.length
+    }
+
+    for ((st, group) <- commands) {
+      val prefix = "  " + String.valueOf(st)
+      val info = prefix +
+        DefaultUsageFormatter.s(prefixIndent - prefix.length) + "  " +
+        group.desc()
+      println(info)
+    }
+
+    print(System.lineSeparator())
+    // scalastyle:off println
+  }
+
+  def printUsageOfJcommander(service: String, action: Option[String],
+      jcommander: JCommander): Unit = {
+    // scalastyle:off println
+    val act = if (action.isEmpty) "[actions]" else action
+    println(s"Usage: kyuubi-ctl ${service} ${act} [options]")
+    if (action.isEmpty) {
+      for (cmd <- jcommander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+    } else {
+      jcommander.setUsageFormatter(new UnixStyleUsage(jcommander))
+      jcommander.usage()
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException).cmd()
+
+    try {
+      serviceCommand.parse(args: _*)
+    } catch {
+      case t: MissingCommandException =>
+        printUsageOfJcommander(String.valueOf(service), Option.empty, serviceCommand)
+        return;
+      case t: ParameterException =>
+        val act = t.getJCommander.getParsedCommand
+        val commander = t.getJCommander.getCommands.get(act)
+        error(s"Parameter error for command: ${act}")
+        printUsageOfJcommander(String.valueOf(service), Option(act), commander)
+        return;
+    }
+
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[Command]).foreach(cmd => {
+      cmd.asInstanceOf[Command].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+    val shell = new KyuubiCli
+
+    if (args == null || args(0).equals("-h") || args(0).equals("--help") || args.length == 1) {

Review comment:
       maybe `args == null` => `args.isEmpty`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-889615397


   maybe we can do it group by group


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672235470



##########
File path: kyuubi-ctl/pom.xml
##########
@@ -109,6 +109,11 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>com.beust</groupId>
+            <artifactId>jcommander</artifactId>
+        </dependency>

Review comment:
       put compile scope deps before thoes test scope

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }

Review comment:
       simplify to 
   ```
   private lazy val commands: Map[ServiceType, JCommander] = Map(
       ServiceType.ENGINE -> JCommander.newBuilder
         .addCommand(new GetEngineCommand)
         .addCommand(new DeleteEngineCommand)
         .addCommand(new ListEngineCommand)
         .build,
   
       ServiceType.SERVER -> JCommander.newBuilder
         .addCommand(new CreateServerCommand)
         .addCommand(new GetServerCommand)
         .addCommand(new DeleteServerCommand)
         .addCommand(new ListServerCommand)
         .build
     )
   ```

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/ListEngineCommand.scala
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters, UnixStyleUsageFormatter}
+
+import org.apache.kyuubi.ctl.commands.common.AbstractCommand
+
+@Parameters(commandNames = Array("list"))
+class ListEngineCommand extends AbstractCommand {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 1)

Review comment:
       all parameters use same`order` value?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672237262



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/ListEngineCommand.scala
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters, UnixStyleUsageFormatter}
+
+import org.apache.kyuubi.ctl.commands.common.AbstractCommand
+
+@Parameters(commandNames = Array("list"))
+class ListEngineCommand extends AbstractCommand {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 1)

Review comment:
       all parameters use same`order` value?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884606002


   Hi @yaooqinn @pan3793 @turboFei, review again when you are free , thanks.
   
   ### cmd examples
   1. input `--help`
   ```
   Usage: kyuubi-ctl <server|engine|config> [actions] [options] 
   
     engine  Commands on operating engine
     server  Commands on operating server
     config  Commands on operating config
   ```
   
   2. input `server --help`
   ```
   Usage: kyuubi-ctl server [actions] [options]
   create
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help       
   get
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help       
   delete
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help       
   list
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help       
   ```
   
   3. input `server get --help`
   ```
   get
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using 
                        zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help 
   ```
   
   ### Easy to add new more service / command
   1. Add new command which extends `Command`
   2. Add the new command to service command group
   3. If add new service type, need to update `Kyuubi`
   4. ok
   
   ![image](https://user-images.githubusercontent.com/86483005/126579899-83b2ef6f-dc22-43d4-baa4-fc7313bc01ce.png)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ba3c25e) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `30.00%`.
   
   > :exclamation: Current head ba3c25e differs from pull request most recent head 45bc1f4. Consider uploading reports for the commit 45bc1f4 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5293     +170     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4078      +51     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...45bc1f4](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672762951



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/AbstractCommand.scala
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import com.beust.jcommander.JCommander
+
+trait AbstractCommand {
+
+  def run(jc: JCommander): Unit = {}

Review comment:
       I'm sorry, I didn't get your points.

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }
+
+  def usage(): Unit = {
+    // scalastyle:off println
+    println("Usage: kyuubi-ctl <server|engine> <create|get|delete|list> [options]")
+    for ((service, commander) <- commands) {
+      println(s"[ $service ]")
+      for (cmd <- commander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+      print(System.lineSeparator())
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException)
+
+    serviceCommand.parse(args: _*)
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[AbstractCommand]).foreach(cmd => {
+      cmd.asInstanceOf[AbstractCommand].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+
+    val shell = new KyuubiCli
+    if (args(0).equals("--help")) {

Review comment:
       right, I'm thinking how to improve it.

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }

Review comment:
       Got.

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/ListEngineCommand.scala
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters, UnixStyleUsageFormatter}
+
+import org.apache.kyuubi.ctl.commands.common.AbstractCommand
+
+@Parameters(commandNames = Array("list"))
+class ListEngineCommand extends AbstractCommand {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 1)

Review comment:
       Good catch.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672762951



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/AbstractCommand.scala
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import com.beust.jcommander.JCommander
+
+trait AbstractCommand {
+
+  def run(jc: JCommander): Unit = {}

Review comment:
       I'm sorry, I didn't get your points.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882584172


   I am planning that we have a command like `kyuubi-ctl [create|get|delete|list] config` or `kyuubi-ctl config [create|get|delete|list]`. with this, which way is right to go? @turboFei @timothy65535 @pan3793 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674457539



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/server/CreateServerCommand.scala
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.server
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("create"))
+class CreateServerCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 2)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 3)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 4)
+  var port: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 5)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO

Review comment:
       ditto




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674457575



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/DeleteEngineCommand.scala
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("delete"))
+class DeleteEngineCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 2)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 3)
+  var port: String = _
+
+  @Parameter(
+    names = Array("-u", "--user"),
+    description = "The user name this engine belong to.",
+    order = 4)
+  var user: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 5)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO

Review comment:
       `TODO` main logic will be put here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674457118



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/DeleteEngineCommand.scala
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("delete"))
+class DeleteEngineCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 2)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 3)
+  var port: String = _
+
+  @Parameter(
+    names = Array("-u", "--user"),
+    description = "The user name this engine belong to.",
+    order = 4)
+  var user: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 5)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO

Review comment:
       what is this for?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (02e34b0) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.48%`.
   > The diff coverage is `40.77%`.
   
   > :exclamation: Current head 02e34b0 differs from pull request most recent head 3e45c86. Consider uploading reports for the commit 3e45c86 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.12%   -1.49%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5320     +197     
     Branches        642      648       +6     
   ============================================
   + Hits           4027     4103      +76     
   - Misses          745      860     +115     
   - Partials        351      357       +6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...kyuubi/engine/spark/operation/SparkOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9vcGVyYXRpb24vU3BhcmtPcGVyYXRpb24uc2NhbGE=) | `68.65% <0.00%> (-1.50%)` | :arrow_down: |
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../apache/kyuubi/client/KyuubiSyncThriftClient.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jbGllbnQvS3l1dWJpU3luY1RocmlmdENsaWVudC5zY2FsYQ==) | `72.72% <ø> (ø)` | |
   | [...ain/scala/org/apache/kyuubi/engine/EngineRef.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvRW5naW5lUmVmLnNjYWxh) | `76.11% <ø> (ø)` | |
   | [...n/scala/org/apache/kyuubi/engine/ProcBuilder.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvUHJvY0J1aWxkZXIuc2NhbGE=) | `91.89% <ø> (ø)` | |
   | ... and [42 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...3e45c86](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672089792



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }
+
+  def usage(): Unit = {
+    // scalastyle:off println
+    println("Usage: kyuubi-ctl <server|engine> <create|get|delete|list> [options]")
+    for ((service, commander) <- commands) {
+      println(s"[ $service ]")
+      for (cmd <- commander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+      print(System.lineSeparator())
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException)
+
+    serviceCommand.parse(args: _*)
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[AbstractCommand]).foreach(cmd => {
+      cmd.asInstanceOf[AbstractCommand].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+
+    val shell = new KyuubiCli
+    if (args(0).equals("--help")) {

Review comment:
       this is hardcoded, uses shall get help whenever an error occurs or they request help explictly




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884606002


   Hi @yaooqinn @pan3793, review again when you are free , thanks.
   
   ### cmd examples
   1. input `--help`
   ```
   Usage: kyuubi-ctl <server|engine|config> [actions] [options] 
   
     engine  Commands on operating engine
     server  Commands on operating server
     config  Commands on operating config
   ```
   
   2. input `server --help`
   ```
   Usage: kyuubi-ctl server [actions] [options]
   create
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help       
   get
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help       
   delete
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help       
   list
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help       
   ```
   
   3. input `server get --help`
   ```
   get
     -zk, --zk-quorum The connection string for the zookeeper ensemble, using 
                        zk quorum manually.
     -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host       Hostname or IP address of a service.
     -p, --port       Listening port of a service.
     -h, --help 
   ```
   
   ### Easy to add new more service / command
   1. Add new command which extends `Command`
   2. Add the new command to service command group
   3. If add new service type, need to update `Kyuubi`
   4. ok
   
   ![image](https://user-images.githubusercontent.com/86483005/126579899-83b2ef6f-dc22-43d4-baa4-fc7313bc01ce.png)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r675145923



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import java.util.{NoSuchElementException, StringJoiner}
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, MissingCommandException, ParameterException}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.commands.common._
+import org.apache.kyuubi.ctl.commands.common.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.config.ConfigCommandGroup
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = Map(
+    ServiceType.engine -> new EngineCommandGroup,
+    ServiceType.server -> new ServerCommandGroup,
+    ServiceType.config -> new ConfigCommandGroup
+  )
+
+  def printAllCommandUsage(): Unit = {
+    // scalastyle:off println
+    val sj = new StringJoiner("|", "<", ">")
+    ServiceType.values.foreach(v => sj.add(String.valueOf(v)))
+    println(s"Usage: kyuubi-ctl ${sj.toString} [actions] [options] \n")

Review comment:
       `${sj.toString}` => `$sj`
   
   maybe can simplify to`ServiceType.values.mkString("|", "<", ">")`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3f5eb6e) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `30.00%`.
   
   > :exclamation: Current head 3f5eb6e differs from pull request most recent head 45bc1f4. Consider uploading reports for the commit 45bc1f4 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5293     +170     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4078      +51     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...45bc1f4](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r679334078



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import java.util.{NoSuchElementException, StringJoiner}
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, MissingCommandException, ParameterException}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.commands.common._
+import org.apache.kyuubi.ctl.commands.common.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.config.ConfigCommandGroup
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = Map(
+    ServiceType.engine -> new EngineCommandGroup,
+    ServiceType.server -> new ServerCommandGroup,
+    ServiceType.config -> new ConfigCommandGroup
+  )
+
+  def printAllCommandUsage(): Unit = {
+    // scalastyle:off println
+    val sj = new StringJoiner("|", "<", ">")
+    ServiceType.values.foreach(v => sj.add(String.valueOf(v)))
+    println(s"Usage: kyuubi-ctl ${sj.toString} [actions] [options] \n")

Review comment:
       `ServiceType.values.mkString("|", "<", ">")` result is `|server<engine<config>`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r675150767



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import java.util.{NoSuchElementException, StringJoiner}
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, MissingCommandException, ParameterException}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.commands.common._
+import org.apache.kyuubi.ctl.commands.common.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.config.ConfigCommandGroup
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = Map(
+    ServiceType.engine -> new EngineCommandGroup,
+    ServiceType.server -> new ServerCommandGroup,
+    ServiceType.config -> new ConfigCommandGroup
+  )
+
+  def printAllCommandUsage(): Unit = {
+    // scalastyle:off println
+    val sj = new StringJoiner("|", "<", ">")
+    ServiceType.values.foreach(v => sj.add(String.valueOf(v)))
+    println(s"Usage: kyuubi-ctl ${sj.toString} [actions] [options] \n")
+    var prefixIndent = 0
+    for (st <- commands.keys) {
+      val prefix = "  " + String.valueOf(st)
+      if (prefix.length > prefixIndent) prefixIndent = prefix.length
+    }
+
+    for ((st, group) <- commands) {
+      val prefix = "  " + String.valueOf(st)
+      val info = prefix +
+        DefaultUsageFormatter.s(prefixIndent - prefix.length) + "  " +
+        group.desc()
+      println(info)
+    }
+
+    print(System.lineSeparator())
+    // scalastyle:off println
+  }
+
+  def printUsageOfJcommander(service: String, action: Option[String],
+      jcommander: JCommander): Unit = {
+    // scalastyle:off println
+    val act = if (action.isEmpty) "[actions]" else action
+    println(s"Usage: kyuubi-ctl ${service} ${act} [options]")
+    if (action.isEmpty) {
+      for (cmd <- jcommander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+    } else {
+      jcommander.setUsageFormatter(new UnixStyleUsage(jcommander))
+      jcommander.usage()
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException).cmd()
+
+    try {
+      serviceCommand.parse(args: _*)
+    } catch {
+      case t: MissingCommandException =>
+        printUsageOfJcommander(String.valueOf(service), Option.empty, serviceCommand)
+        return;
+      case t: ParameterException =>
+        val act = t.getJCommander.getParsedCommand
+        val commander = t.getJCommander.getCommands.get(act)
+        error(s"Parameter error for command: ${act}")
+        printUsageOfJcommander(String.valueOf(service), Option(act), commander)
+        return;
+    }
+
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[Command]).foreach(cmd => {
+      cmd.asInstanceOf[Command].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+    val shell = new KyuubiCli
+
+    if (args == null || args(0).equals("-h") || args(0).equals("--help") || args.length == 1) {

Review comment:
       is it feasible to leverage JCommander parser the top-level args? if does, let's also support `-v` `--version`  




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674456701



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/UnixStyleUsage.scala
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import java.lang.{StringBuilder => Builder}
+import java.util.List
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, ParameterDescription}
+
+class UnixStyleUsage(commander: JCommander) extends DefaultUsageFormatter(commander) {
+
+  override def appendMainLine(out: Builder, hasOptions: Boolean,
+                              hasCommands: Boolean, indentCount: Int, indent: String): Unit = {
+    wrapDescription(out, indentCount, commander.getProgramDisplayName + "\n")
+  }
+
+  override def appendAllParametersDetails(out: Builder, indentCount: Int, indent: String,
+                                          sortedParameters: List[ParameterDescription]): Unit = {

Review comment:
       ```suggestion
     override def appendAllParametersDetails(out: Builder, indentCount: Int, indent: String,
         sortedParameters: List[ParameterDescription]): Unit = {
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674457892



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/GetEngineCommand.scala
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters}
+import com.google.common.annotations.VisibleForTesting
+
+import org.apache.kyuubi.ctl.commands.common.{Command, UnixStyleUsage}
+
+@Parameters(commandNames = Array("get"))
+class GetEngineCommand extends Command {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 2)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 3)
+  var host: String = _
+
+  @Parameter(
+    names = Array("-p", "--port"),
+    description = "Listening port of a service.",
+    order = 4)
+  var port: Int = _
+
+  @Parameter(
+    names = Array("-u", "--user"),
+    description = "The user name this engine belong to.",
+    order = 5)
+  var user: String = _
+
+  @Parameter(names = Array("-h", "--help"), help = true, order = 6)
+  var help: Boolean = false
+
+  override def run(jc: JCommander): Unit = {
+    if (help) {
+      jc.setUsageFormatter(new UnixStyleUsage(jc))
+      jc.usage()
+    } else {
+      // TODO
+    }
+  }
+
+  @VisibleForTesting
+  def test(): (String, String, Int) = {

Review comment:
       yes. it's used for testing. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r675153546



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/UnixStyleUsage.scala
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import java.lang.{StringBuilder => Builder}

Review comment:
       why rename?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672235470



##########
File path: kyuubi-ctl/pom.xml
##########
@@ -109,6 +109,11 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>com.beust</groupId>
+            <artifactId>jcommander</artifactId>
+        </dependency>

Review comment:
       put compile scope deps before thoes test scope

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }

Review comment:
       simplify to 
   ```
   private lazy val commands: Map[ServiceType, JCommander] = Map(
       ServiceType.ENGINE -> JCommander.newBuilder
         .addCommand(new GetEngineCommand)
         .addCommand(new DeleteEngineCommand)
         .addCommand(new ListEngineCommand)
         .build,
   
       ServiceType.SERVER -> JCommander.newBuilder
         .addCommand(new CreateServerCommand)
         .addCommand(new GetServerCommand)
         .addCommand(new DeleteServerCommand)
         .addCommand(new ListServerCommand)
         .build
     )
   ```

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/ListEngineCommand.scala
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters, UnixStyleUsageFormatter}
+
+import org.apache.kyuubi.ctl.commands.common.AbstractCommand
+
+@Parameters(commandNames = Array("list"))
+class ListEngineCommand extends AbstractCommand {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 1)

Review comment:
       all parameters use same`order` value?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882550421


   After second thought and have a discussion with @turboFei (author of this the first version of `kyuubi-ctl`),  I change my vote to `kyuubi-ctl <create|get|delete|list> <server|engine> options`. It's because
   1. some tools use `cmd action object`, i.e. `kubectl`, some tools chose `cmd subcmd subcmd`, both are widely used.
   2. one of the fact is that `kyuubi-ctl list service` and `kyuubi-ctl list engine` are almost the same things except for the `znode root path`, and we can reuse lots code if chose the pattern `cmd action object`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r674451799



##########
File path: kyuubi-ctl/pom.xml
##########
@@ -109,6 +109,11 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>com.beust</groupId>
+            <artifactId>jcommander</artifactId>
+        </dependency>

Review comment:
       done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672087080



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/AbstractCommand.scala
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import com.beust.jcommander.JCommander
+
+trait AbstractCommand {
+
+  def run(jc: JCommander): Unit = {}

Review comment:
       Can we have possible output for each command?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884605926


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#826](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (90b8ccf) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/bf0042cbff2c2b70622d5be20784b00fdf8480e0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf0042c) will **decrease** coverage by `1.56%`.
   > The diff coverage is `30.00%`.
   
   > :exclamation: Current head 90b8ccf differs from pull request most recent head 2321eff. Consider uploading reports for the commit 2321eff to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #826      +/-   ##
   ============================================
   - Coverage     78.60%   77.04%   -1.57%     
     Complexity       10       10              
   ============================================
     Files           135      149      +14     
     Lines          5123     5293     +170     
     Branches        642      646       +4     
   ============================================
   + Hits           4027     4078      +51     
   - Misses          745      859     +114     
   - Partials        351      356       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/kyuubi/ctl/commands/common/UnixStyleUsage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29tbW9uL1VuaXhTdHlsZVVzYWdlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/config/SetConfigCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL1NldENvbmZpZ0NvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/CreateServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0NyZWF0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/server/DeleteServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0RlbGV0ZVNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [.../kyuubi/ctl/commands/server/GetServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0dldFNlcnZlckNvbW1hbmQuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...kyuubi/ctl/commands/server/ListServerCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL0xpc3RTZXJ2ZXJDb21tYW5kLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [...uubi/ctl/commands/engine/DeleteEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0RlbGV0ZUVuZ2luZUNvbW1hbmQuc2NhbGE=) | `18.18% <18.18%> (ø)` | |
   | [...kyuubi/ctl/commands/engine/ListEngineCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvZW5naW5lL0xpc3RFbmdpbmVDb21tYW5kLnNjYWxh) | `18.18% <18.18%> (ø)` | |
   | [...yuubi/ctl/commands/server/ServerCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvc2VydmVyL1NlcnZlckNvbW1hbmRHcm91cC5zY2FsYQ==) | `22.22% <22.22%> (ø)` | |
   | [...yuubi/ctl/commands/config/ConfigCommandGroup.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY29tbWFuZHMvY29uZmlnL0NvbmZpZ0NvbW1hbmRHcm91cC5zY2FsYQ==) | `33.33% <33.33%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/826/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf0042c...2321eff](https://codecov.io/gh/apache/incubator-kyuubi/pull/826?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882584172






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882550421






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672235815



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }

Review comment:
       simplify to 
   ```
   private lazy val commands: Map[ServiceType, JCommander] = Map(
       ServiceType.ENGINE -> JCommander.newBuilder
         .addCommand(new GetEngineCommand)
         .addCommand(new DeleteEngineCommand)
         .addCommand(new ListEngineCommand)
         .build,
   
       ServiceType.SERVER -> JCommander.newBuilder
         .addCommand(new CreateServerCommand)
         .addCommand(new GetServerCommand)
         .addCommand(new DeleteServerCommand)
         .addCommand(new ListServerCommand)
         .build
     )
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884617534


   > Hi @yaooqinn @pan3793 @turboFei, review again when you are free , thanks.
   > 
   > ### cmd examples
   > 1. input `--help`
   > 
   > ```
   > Usage: kyuubi-ctl <server|engine|config> [actions] [options] 
   > 
   >   engine  Commands on operating engine
   >   server  Commands on operating server
   >   config  Commands on operating config
   > ```
   > 
   > 1. input `server --help`
   > 
   > ```
   > Usage: kyuubi-ctl server [actions] [options]
   > create
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > get
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > delete
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > list
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > ```
   > 
   > 1. input `server get --help`
   > 
   > ```
   > get
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using 
   >                      zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help 
   > ```
   > 
   > ### Easy to add new more service / command
   > 1. Add new command which extends `Command`
   > 2. Add the new command to service command group
   > 3. If add new service type, need to update `Kyuubi`
   > 4. ok
   > 
   > ![image](https://user-images.githubusercontent.com/86483005/126579899-83b2ef6f-dc22-43d4-baa4-fc7313bc01ce.png)
   
   the behavior changes a lot for each command, the acceptable args change from cmd to cmd. I can not remember each very well, but the create server logic seems to be wrong according to the help instructions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884612198


   cc @turboFei PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672763327



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/ListEngineCommand.scala
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters, UnixStyleUsageFormatter}
+
+import org.apache.kyuubi.ctl.commands.common.AbstractCommand
+
+@Parameters(commandNames = Array("list"))
+class ListEngineCommand extends AbstractCommand {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 1)

Review comment:
       Good catch.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 edited a comment on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 edited a comment on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884621581


   Each different command uses its own command parameters to be more extensible.
   
   We can discuss it here, it's not must to introduce the jcommander framework.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884617534


   > Hi @yaooqinn @pan3793 @turboFei, review again when you are free , thanks.
   > 
   > ### cmd examples
   > 1. input `--help`
   > 
   > ```
   > Usage: kyuubi-ctl <server|engine|config> [actions] [options] 
   > 
   >   engine  Commands on operating engine
   >   server  Commands on operating server
   >   config  Commands on operating config
   > ```
   > 
   > 1. input `server --help`
   > 
   > ```
   > Usage: kyuubi-ctl server [actions] [options]
   > create
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > get
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > delete
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > list
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help       
   > ```
   > 
   > 1. input `server get --help`
   > 
   > ```
   > get
   >   -zk, --zk-quorum The connection string for the zookeeper ensemble, using 
   >                      zk quorum manually.
   >   -n, --namespace  The namespace, using kyuubi-defaults/conf if absent.
   >   -s, --host       Hostname or IP address of a service.
   >   -p, --port       Listening port of a service.
   >   -h, --help 
   > ```
   > 
   > ### Easy to add new more service / command
   > 1. Add new command which extends `Command`
   > 2. Add the new command to service command group
   > 3. If add new service type, need to update `Kyuubi`
   > 4. ok
   > 
   > ![image](https://user-images.githubusercontent.com/86483005/126579899-83b2ef6f-dc22-43d4-baa4-fc7313bc01ce.png)
   
   the behavior changes a lot for each command, the acceptable args change from cmd to cmd


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884621072


   The usage in master branch 
   ```
   Usage: kyuubi-ctl [create|get|delete|list] [options]
   
     -zk, --zk-quorum <value>
                              The connection string for the zookeeper ensemble, using zk quorum manually.
     -n, --namespace <value>  The namespace, using kyuubi-defaults/conf if absent.
     -s, --host <value>       Hostname or IP address of a service.
     -p, --port <value>       Listening port of a service.
     -v, --version <value>    Using the compiled KYUUBI_VERSION default, change it if the active service is running in another.
     -b, --verbose            Print additional debug output.
   
   Command: create [server]
   
   Command: create server
           Expose Kyuubi server instance to another domain.
   
   Command: get [server|engine] [options]
           Get the service/engine node info, host and port needed.
   Command: get server
           Get Kyuubi server info of domain
   Command: get engine
           Get Kyuubi engine info belong to a user.
     -u, --user <value>       The user name this engine belong to.
   
   Command: delete [server|engine] [options]
           Delete the specified service/engine node, host and port needed.
   Command: delete server
           Delete the specified service node for a domain
   Command: delete engine
           Delete the specified engine node for user.
     -u, --user <value>       The user name this engine belong to.
   
   Command: list [server|engine] [options]
           List all the service/engine nodes for a particular domain.
   Command: list server
           List all the service nodes for a particular domain
   Command: list engine
           List all the engine nodes for a user
     -u, --user <value>       The user name this engine belong to.
   
     -h, --help               Show help message and exit.
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672762951



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/common/AbstractCommand.scala
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.common
+
+import com.beust.jcommander.JCommander
+
+trait AbstractCommand {
+
+  def run(jc: JCommander): Unit = {}

Review comment:
       I'm sorry, I didn't get your points.

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }
+
+  def usage(): Unit = {
+    // scalastyle:off println
+    println("Usage: kyuubi-ctl <server|engine> <create|get|delete|list> [options]")
+    for ((service, commander) <- commands) {
+      println(s"[ $service ]")
+      for (cmd <- commander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+      print(System.lineSeparator())
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException)
+
+    serviceCommand.parse(args: _*)
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[AbstractCommand]).foreach(cmd => {
+      cmd.asInstanceOf[AbstractCommand].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+
+    val shell = new KyuubiCli
+    if (args(0).equals("--help")) {

Review comment:
       right, I'm thinking how to improve it.

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }

Review comment:
       Got.

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/commands/engine/ListEngineCommand.scala
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl.commands.engine
+
+import com.beust.jcommander.{JCommander, Parameter, Parameters, UnixStyleUsageFormatter}
+
+import org.apache.kyuubi.ctl.commands.common.AbstractCommand
+
+@Parameters(commandNames = Array("list"))
+class ListEngineCommand extends AbstractCommand {
+
+  @Parameter(
+    names = Array("-zk", "--zk-quorum"),
+    description = "The connection string for the zookeeper ensemble, using zk quorum manually.",
+    order = 1)
+  var zkQuorum: String = _
+
+  @Parameter(
+    names = Array("-n", "--namespace"),
+    description = "The namespace, using kyuubi-defaults/conf if absent.",
+    order = 1)
+  var namespace: String = _
+
+  @Parameter(
+    names = Array("-s", "--host"),
+    description = "Hostname or IP address of a service.",
+    order = 1)

Review comment:
       Good catch.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r675152168



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import java.util.{NoSuchElementException, StringJoiner}
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, MissingCommandException, ParameterException}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.commands.common._
+import org.apache.kyuubi.ctl.commands.common.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.config.ConfigCommandGroup
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = Map(
+    ServiceType.engine -> new EngineCommandGroup,
+    ServiceType.server -> new ServerCommandGroup,
+    ServiceType.config -> new ConfigCommandGroup
+  )
+
+  def printAllCommandUsage(): Unit = {
+    // scalastyle:off println
+    val sj = new StringJoiner("|", "<", ">")
+    ServiceType.values.foreach(v => sj.add(String.valueOf(v)))
+    println(s"Usage: kyuubi-ctl ${sj.toString} [actions] [options] \n")
+    var prefixIndent = 0
+    for (st <- commands.keys) {
+      val prefix = "  " + String.valueOf(st)
+      if (prefix.length > prefixIndent) prefixIndent = prefix.length
+    }
+
+    for ((st, group) <- commands) {
+      val prefix = "  " + String.valueOf(st)
+      val info = prefix +
+        DefaultUsageFormatter.s(prefixIndent - prefix.length) + "  " +
+        group.desc()
+      println(info)
+    }
+
+    print(System.lineSeparator())
+    // scalastyle:off println
+  }
+
+  def printUsageOfJcommander(service: String, action: Option[String],
+      jcommander: JCommander): Unit = {
+    // scalastyle:off println
+    val act = if (action.isEmpty) "[actions]" else action
+    println(s"Usage: kyuubi-ctl ${service} ${act} [options]")
+    if (action.isEmpty) {
+      for (cmd <- jcommander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+    } else {
+      jcommander.setUsageFormatter(new UnixStyleUsage(jcommander))
+      jcommander.usage()
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException).cmd()
+
+    try {
+      serviceCommand.parse(args: _*)
+    } catch {
+      case t: MissingCommandException =>
+        printUsageOfJcommander(String.valueOf(service), Option.empty, serviceCommand)
+        return;
+      case t: ParameterException =>
+        val act = t.getJCommander.getParsedCommand
+        val commander = t.getJCommander.getCommands.get(act)
+        error(s"Parameter error for command: ${act}")
+        printUsageOfJcommander(String.valueOf(service), Option(act), commander)
+        return;
+    }
+
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[Command]).foreach(cmd => {
+      cmd.asInstanceOf[Command].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+    val shell = new KyuubiCli
+
+    if (args == null || args(0).equals("-h") || args(0).equals("--help") || args.length == 1) {
+      shell.printAllCommandUsage()
+    } else {
+      try {
+        shell.run(ServiceType.withName(args(0)), args.drop(1))
+      } catch {
+        case _: NoSuchElementException =>
+          error(s"unknown service type: args(0)")

Review comment:
       `args(0)` => `${args.head}`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r679350496



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import java.util.{NoSuchElementException, StringJoiner}
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, MissingCommandException, ParameterException}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.commands.common._
+import org.apache.kyuubi.ctl.commands.common.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.config.ConfigCommandGroup
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = Map(
+    ServiceType.engine -> new EngineCommandGroup,
+    ServiceType.server -> new ServerCommandGroup,
+    ServiceType.config -> new ConfigCommandGroup
+  )
+
+  def printAllCommandUsage(): Unit = {
+    // scalastyle:off println
+    val sj = new StringJoiner("|", "<", ">")
+    ServiceType.values.foreach(v => sj.add(String.valueOf(v)))
+    println(s"Usage: kyuubi-ctl ${sj.toString} [actions] [options] \n")
+    var prefixIndent = 0
+    for (st <- commands.keys) {
+      val prefix = "  " + String.valueOf(st)
+      if (prefix.length > prefixIndent) prefixIndent = prefix.length
+    }
+
+    for ((st, group) <- commands) {
+      val prefix = "  " + String.valueOf(st)
+      val info = prefix +
+        DefaultUsageFormatter.s(prefixIndent - prefix.length) + "  " +
+        group.desc()
+      println(info)
+    }
+
+    print(System.lineSeparator())
+    // scalastyle:off println
+  }
+
+  def printUsageOfJcommander(service: String, action: Option[String],
+      jcommander: JCommander): Unit = {
+    // scalastyle:off println
+    val act = if (action.isEmpty) "[actions]" else action
+    println(s"Usage: kyuubi-ctl ${service} ${act} [options]")
+    if (action.isEmpty) {
+      for (cmd <- jcommander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+    } else {
+      jcommander.setUsageFormatter(new UnixStyleUsage(jcommander))
+      jcommander.usage()
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException).cmd()
+
+    try {
+      serviceCommand.parse(args: _*)
+    } catch {
+      case t: MissingCommandException =>
+        printUsageOfJcommander(String.valueOf(service), Option.empty, serviceCommand)
+        return;
+      case t: ParameterException =>
+        val act = t.getJCommander.getParsedCommand
+        val commander = t.getJCommander.getCommands.get(act)
+        error(s"Parameter error for command: ${act}")
+        printUsageOfJcommander(String.valueOf(service), Option(act), commander)
+        return;
+    }
+
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[Command]).foreach(cmd => {
+      cmd.asInstanceOf[Command].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+    val shell = new KyuubiCli
+
+    if (args == null || args(0).equals("-h") || args(0).equals("--help") || args.length == 1) {

Review comment:
       `-v` `--version` is option for each command? 
   
   It seems the `-v` param is never used in original command.
   ![image](https://user-images.githubusercontent.com/86483005/127537331-445dc573-ac3a-4264-80d9-3c0b2e3f6400.png)
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672235470



##########
File path: kyuubi-ctl/pom.xml
##########
@@ -109,6 +109,11 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>com.beust</groupId>
+            <artifactId>jcommander</artifactId>
+        </dependency>

Review comment:
       put compile scope deps before thoes test scope




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882584172






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r675145923



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import java.util.{NoSuchElementException, StringJoiner}
+
+import scala.collection.JavaConverters._
+
+import com.beust.jcommander.{DefaultUsageFormatter, JCommander, MissingCommandException, ParameterException}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.commands.common._
+import org.apache.kyuubi.ctl.commands.common.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.config.ConfigCommandGroup
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = Map(
+    ServiceType.engine -> new EngineCommandGroup,
+    ServiceType.server -> new ServerCommandGroup,
+    ServiceType.config -> new ConfigCommandGroup
+  )
+
+  def printAllCommandUsage(): Unit = {
+    // scalastyle:off println
+    val sj = new StringJoiner("|", "<", ">")
+    ServiceType.values.foreach(v => sj.add(String.valueOf(v)))
+    println(s"Usage: kyuubi-ctl ${sj.toString} [actions] [options] \n")

Review comment:
       `${sj.toString}` => `$sj`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-889770977


   > maybe we can do it group by group
   
   First step is introduce framework to kyuubi project, we can discuss the design of the command frammework.
   
   Next plan:
   - [ ] Implement engine part
   - [ ] Implement service part
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-884621581


   Each different command uses its own command parameters to be more extensible.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r675145348



##########
File path: kyuubi-ctl/pom.xml
##########
@@ -109,6 +114,7 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+

Review comment:
       Unnecessary change




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] timothy65535 commented on a change in pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
timothy65535 commented on a change in pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#discussion_r672763142



##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }
+
+  def usage(): Unit = {
+    // scalastyle:off println
+    println("Usage: kyuubi-ctl <server|engine> <create|get|delete|list> [options]")
+    for ((service, commander) <- commands) {
+      println(s"[ $service ]")
+      for (cmd <- commander.getCommands.values().asScala) {
+        cmd.setColumnSize(100)
+        cmd.setUsageFormatter(new UnixStyleUsage(cmd))
+        cmd.usage()
+      }
+      print(System.lineSeparator())
+    }
+    // scalastyle:off println
+  }
+
+  def run(service: ServiceType, args: Array[String]): Unit = {
+
+    val serviceCommand = commands.getOrElse(service, throw new RuntimeException)
+
+    serviceCommand.parse(args: _*)
+    val parsedCommand = serviceCommand.getCommands.get(serviceCommand.getParsedCommand)
+    parsedCommand.getObjects.asScala.find(_.isInstanceOf[AbstractCommand]).foreach(cmd => {
+      cmd.asInstanceOf[AbstractCommand].run(parsedCommand)
+    })
+
+  }
+
+}
+
+object KyuubiCli extends Logging {
+
+  def main(args: Array[String]): Unit = {
+
+    val shell = new KyuubiCli
+    if (args(0).equals("--help")) {

Review comment:
       right, I'm thinking how to improve it.

##########
File path: kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/KyuubiCli.scala
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.ctl
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.beust.jcommander.JCommander
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.ctl.ServiceType.ServiceType
+import org.apache.kyuubi.ctl.commands.common.{AbstractCommand, UnixStyleUsage}
+import org.apache.kyuubi.ctl.commands.engine._
+import org.apache.kyuubi.ctl.commands.server._
+
+private[ctl] object ServiceType extends Enumeration {
+  type ServiceType = Value
+  val SERVER, ENGINE = Value
+}
+
+class KyuubiCli extends Logging {
+
+  private lazy val commands = initCommands()
+
+  def initCommands(): HashMap[ServiceType, JCommander] = {
+    // init engine commands
+    val engineCommand = JCommander
+      .newBuilder()
+      .addCommand(new GetEngineCommand)
+      .addCommand(new DeleteEngineCommand)
+      .addCommand(new ListEngineCommand)
+      .build()
+
+    // init server commands
+    val serverCommand = JCommander
+      .newBuilder()
+      .addCommand(new CreateServerCommand)
+      .addCommand(new GetServerCommand)
+      .addCommand(new DeleteServerCommand)
+      .addCommand(new ListServerCommand)
+      .build()
+
+    // register commands
+    HashMap(
+      ServiceType.ENGINE -> engineCommand,
+      ServiceType.SERVER -> serverCommand
+    )
+  }

Review comment:
       Got.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on pull request #826: [KYUUBI #825] Introduce jcommander framework to kyuubi project

Posted by GitBox <gi...@apache.org>.
pan3793 commented on pull request #826:
URL: https://github.com/apache/incubator-kyuubi/pull/826#issuecomment-882550421






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org