This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 9d740265a0c CAMEL-18074: camel-jbang - Polish usage description and 
show version for -V
9d740265a0c is described below

commit 9d740265a0cc4995de8a9a65d7a6741d5245ce88
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sat May 7 08:42:13 2022 +0200

    CAMEL-18074: camel-jbang - Polish usage description and show version for -V
---
 .../dsl/jbang/core/commands/CamelJBangMain.java    | 12 +++++--
 .../camel/dsl/jbang/core/commands/Version.java     | 42 ----------------------
 2 files changed, 9 insertions(+), 45 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index 721d23b9178..a23636dd943 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -18,17 +18,17 @@ package org.apache.camel.dsl.jbang.core.commands;
 
 import java.util.concurrent.Callable;
 
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
 import picocli.CommandLine;
 import picocli.CommandLine.Command;
 
-@Command(name = "CamelJBang", mixinStandardHelpOptions = true, version = 
"CamelJBang",
-         description = "A JBang-based Camel app")
+@Command(name = "camel", description = "Apache Camel CLI", 
mixinStandardHelpOptions = true)
 public class CamelJBangMain implements Callable<Integer> {
     private static CommandLine commandLine;
 
     public static void run(String... args) {
         commandLine = new CommandLine(new CamelJBangMain())
-                .addSubcommand("version", new CommandLine(new Version()))
                 .addSubcommand("run", new CommandLine(new Run()))
                 .addSubcommand("init", new CommandLine(new Init()))
                 .addSubcommand("bind", new CommandLine(new Bind()))
@@ -49,6 +49,12 @@ public class CamelJBangMain implements Callable<Integer> {
                 .addSubcommand("create", new CommandLine(new Create())
                         .addSubcommand("project", new Project()));
 
+        commandLine.getCommandSpec().versionProvider(() -> {
+            CamelCatalog catalog = new DefaultCamelCatalog();
+            String v = catalog.getCatalogVersion();
+            return new String[]{v};
+        });
+
         PropertiesHelper.augmentWithProperties(commandLine);
         int exitCode = commandLine.execute(args);
         System.exit(exitCode);
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Version.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Version.java
deleted file mode 100644
index 6219c940606..00000000000
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Version.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.camel.dsl.jbang.core.commands;
-
-import java.util.concurrent.Callable;
-
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.catalog.DefaultCamelCatalog;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "init", description = "Display Camel version")
-class Version implements Callable<Integer> {
-
-    //CHECKSTYLE:OFF
-    @Option(names = { "-h", "--help" }, usageHelp = true, description = 
"Display the help and sub-commands")
-    private boolean helpRequested = false;
-    //CHECKSTYLE:ON
-
-    @Override
-    public Integer call() throws Exception {
-        CamelCatalog catalog = new DefaultCamelCatalog();
-        String v = catalog.getCatalogVersion();
-        System.out.println("Camel JBang " + v);
-        return 0;
-    }
-
-}

Reply via email to