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 68f1c43a02f3 CAMEL-23663: camel-jbang - Add config to turn off plugin
banner in --help (#23682)
68f1c43a02f3 is described below
commit 68f1c43a02f3131d9a6b6887cc4e50f3beeec9e9
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Jun 1 22:25:07 2026 +0200
CAMEL-23663: camel-jbang - Add config to turn off plugin banner in --help
(#23682)
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude <[email protected]>
---
.../dsl/jbang/core/commands/CamelJBangMain.java | 15 ++++-
.../jbang/core/commands/CamelJBangMainTest.java | 70 ++++++++++++++++++++++
2 files changed, 84 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 e5102ba30f99..5242455b5dd8 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
@@ -293,7 +293,19 @@ public class CamelJBangMain implements Callable<Integer> {
return false;
}
- private void printAvailablePlugins() {
+ void printAvailablePlugins() {
+ // check if the plugin banner is disabled via global config
+ boolean[] enabled = { true };
+ CommandLineHelper.loadProperties(properties -> {
+ String v = properties.getProperty("camel.jbang.plugin.banner");
+ if ("false".equalsIgnoreCase(v)) {
+ enabled[0] = false;
+ }
+ });
+ if (!enabled[0]) {
+ return;
+ }
+
Set<String> installed = new HashSet<>();
JsonObject config = PluginHelper.getPluginConfig();
if (config != null) {
@@ -330,6 +342,7 @@ public class CamelJBangMain implements Callable<Integer> {
out.println();
out.println("Tip: Install with: camel plugin add <name>");
out.println(" Bundled plugins are auto-installed on first
use.");
+ out.println(" Turn off: camel config set
camel.jbang.plugin.banner=false");
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMainTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMainTest.java
new file mode 100644
index 000000000000..23b9e6dca1df
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMainTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.lang.reflect.Field;
+import java.util.List;
+
+import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
+import org.apache.camel.dsl.jbang.core.common.PluginHelper;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import picocli.CommandLine;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class CamelJBangMainTest extends CamelCommandBaseTestSupport {
+
+ private CamelJBangMain main;
+
+ @BeforeEach
+ public void setup() throws Exception {
+ super.setup();
+
+ CommandLineHelper.useHomeDir("target");
+ PluginHelper.createPluginConfig();
+
+ main = new CamelJBangMain().withPrinter(printer);
+
+ // set the static commandLine field so printAvailablePlugins() can
check subcommands
+ Field f = CamelJBangMain.class.getDeclaredField("commandLine");
+ f.setAccessible(true);
+ f.set(null, new CommandLine(main));
+ }
+
+ @Test
+ public void shouldShowPluginBannerByDefault() throws Exception {
+ UserConfigHelper.createUserConfig("");
+
+ main.printAvailablePlugins();
+
+ List<String> output = printer.getLines();
+ assertTrue(output.stream().anyMatch(l -> l.contains("Plugins (not
installed):")));
+ assertTrue(output.stream().anyMatch(l -> l.contains("Turn off: camel
config set camel.jbang.plugin.banner=false")));
+ }
+
+ @Test
+ public void shouldHidePluginBannerWhenDisabled() throws Exception {
+ UserConfigHelper.createUserConfig("camel.jbang.plugin.banner=false");
+
+ main.printAvailablePlugins();
+
+ List<String> output = printer.getLines();
+ assertFalse(output.stream().anyMatch(l -> l.contains("Plugins (not
installed):")));
+ }
+}