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 c86f7405c3f camel-jbang - Add version command
c86f7405c3f is described below

commit c86f7405c3faec3f43e431808b36d1c38381f8f9
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Apr 28 16:11:47 2022 +0200

    camel-jbang - Add version command
---
 .../dsl/jbang/core/commands/CamelJBangMain.java    |  3 +-
 .../camel/dsl/jbang/core/commands/Version.java     | 57 ++++++++++++++++++++++
 2 files changed, 59 insertions(+), 1 deletion(-)

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 00c3b149cb4..721d23b9178 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
@@ -28,7 +28,8 @@ public class CamelJBangMain implements Callable<Integer> {
 
     public static void run(String... args) {
         commandLine = new CommandLine(new CamelJBangMain())
-                .addSubcommand("run", new Run())
+                .addSubcommand("version", new CommandLine(new Version()))
+                .addSubcommand("run", new CommandLine(new Run()))
                 .addSubcommand("init", new CommandLine(new Init()))
                 .addSubcommand("bind", new CommandLine(new Bind()))
                 .addSubcommand("package", new CommandLine(new Package())
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
new file mode 100644
index 00000000000..94512c3e0a4
--- /dev/null
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Version.java
@@ -0,0 +1,57 @@
+/*
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.dsl.jbang.core.common.exceptions.ResourceDoesNotExist;
+import org.apache.camel.github.GitHubResourceResolver;
+import org.apache.camel.impl.lw.LightweightCamelContext;
+import org.apache.camel.spi.Resource;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
+import org.apache.commons.io.IOUtils;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.StringJoiner;
+import java.util.concurrent.Callable;
+
+import static 
org.apache.camel.dsl.jbang.core.commands.GitHubHelper.asGithubSingleUrl;
+import static 
org.apache.camel.dsl.jbang.core.commands.GitHubHelper.fetchGithubUrls;
+
+@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