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 6a0fbc8225b0 CAMEL-23423: camel-jbang - diagram command to have
theme=text
6a0fbc8225b0 is described below
commit 6a0fbc8225b058fa760ec54afa7e11439f843351
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed May 6 14:20:03 2026 +0200
CAMEL-23423: camel-jbang - diagram command to have theme=text
---
.../pages/jbang-commands/camel-jbang-cmd-route-diagram.adoc | 2 +-
.../resources/META-INF/camel-jbang-commands-metadata.json | 2 +-
.../jbang/core/commands/action/CamelRouteDiagramAction.java | 13 ++++++++++---
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-cmd-route-diagram.adoc
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-cmd-route-diagram.adoc
index 5741b65b6c0a..9f854b762ff9 100644
---
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-cmd-route-diagram.adoc
+++
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-cmd-route-diagram.adoc
@@ -25,7 +25,7 @@ camel cmd route-diagram [options]
| `--ignore-loading-error` | Whether to ignore route loading and compilation
errors (use this with care!) | false | boolean
| `--node-label` | What text to display in diagram nodes: code, description,
or both (default) | both | String
| `--output` | Save diagram to a PNG file instead of displaying in terminal |
| String
-| `--theme,--colors` | Color theme preset (dark, light, transparent) or custom
colors (e.g. bg=#1e1e1e:from=#2e7d32:to=#1565c0). Values can be #hex or ANSI
color names (e.g. from=seagreen:to=steelblue). Use bg= for transparent. Can
also be set via DIAGRAM_COLORS env var. | dark | String
+| `--theme,--colors` | Color theme preset (dark, light, transparent, text) or
custom colors (e.g. bg=#1e1e1e:from=#2e7d32:to=#1565c0). Values can be #hex or
ANSI color names (e.g. from=seagreen:to=steelblue). Use bg= for transparent.
Can also be set via DIAGRAM_COLORS env var. | dark | String
| `--width` | Image width in pixels (0 = auto) | 0 | int
| `-h,--help` | Display the help and sub-commands | | boolean
|===
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
index 86ff873fd444..77069a1e6a8b 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
+++
b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
@@ -2,7 +2,7 @@
"commands": [
{ "name": "bind", "fullName": "bind", "description": "DEPRECATED: Bind
source and sink Kamelets as a new Camel integration", "deprecated": true,
"sourceClass": "org.apache.camel.dsl.jbang.core.commands.bind.Bind", "options":
[ { "names": "--error-handler", "description": "Add error handler
(none|log|sink:<endpoint>). Sink endpoints are expected in the format
[[apigroup\/]version:]kind:[namespace\/]name, plain Camel URIs or Kamelet
name.", "javaType": "java.lang.String", "type": "stri [...]
{ "name": "catalog", "fullName": "catalog", "description": "List artifacts
from Camel Catalog", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.catalog.CatalogCommand", "options": [
{ "names": "-h,--help", "description": "Display the help and sub-commands",
"javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name":
"component", "fullName": "catalog component", "description": "List components
from the Camel Catalog", "sourceClass": "org.apache.camel.dsl.jbang.co [...]
- { "name": "cmd", "fullName": "cmd", "description": "Performs commands in
the running Camel integrations, such as start\/stop route, or change logging
levels.", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.action.CamelAction", "options": [ {
"names": "-h,--help", "description": "Display the help and sub-commands",
"javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name":
"browse", "fullName": "cmd browse", "description": "Browse pending messages on
endpoints [...]
+ { "name": "cmd", "fullName": "cmd", "description": "Performs commands in
the running Camel integrations, such as start\/stop route, or change logging
levels.", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.action.CamelAction", "options": [ {
"names": "-h,--help", "description": "Display the help and sub-commands",
"javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name":
"browse", "fullName": "cmd browse", "description": "Browse pending messages on
endpoints [...]
{ "name": "completion", "fullName": "completion", "description": "Generate
completion script for bash\/zsh", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.Complete", "options": [ { "names":
"-h,--help", "description": "Display the help and sub-commands", "javaType":
"boolean", "type": "boolean" } ] },
{ "name": "config", "fullName": "config", "description": "Get and set user
configuration values", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.config.ConfigCommand", "options": [ {
"names": "-h,--help", "description": "Display the help and sub-commands",
"javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name": "get",
"fullName": "config get", "description": "Display user configuration value",
"sourceClass": "org.apache.camel.dsl.jbang.core.commands.config. [...]
{ "name": "debug", "fullName": "debug", "description": "Debug local Camel
integration", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Debug",
"options": [ { "names": "--ago", "description": "Use ago instead of yyyy-MM-dd
HH:mm:ss in timestamp.", "javaType": "boolean", "type": "boolean" }, { "names":
"--background", "description": "Run in the background", "defaultValue":
"false", "javaType": "boolean", "type": "boolean" }, { "names":
"--background-wait", "description": "To [...]
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramAction.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramAction.java
index 79cbe5456ad4..15e85d15b10e 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramAction.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramAction.java
@@ -68,7 +68,7 @@ public class CamelRouteDiagramAction extends
ActionBaseCommand {
String output;
@CommandLine.Option(names = { "--theme", "--colors" },
- description = "Color theme preset (dark, light,
transparent) or custom colors "
+ description = "Color theme preset (dark, light,
transparent, text) or custom colors "
+ "(e.g.
bg=#1e1e1e:from=#2e7d32:to=#1565c0). Values can be #hex or "
+ "ANSI color names (e.g.
from=seagreen:to=steelblue). "
+ "Use bg= for transparent. Can also be
set via DIAGRAM_COLORS env var.",
@@ -138,7 +138,7 @@ public class CamelRouteDiagramAction extends
ActionBaseCommand {
System.setProperty("java.awt.headless", "true");
String colorSpec = System.getenv("DIAGRAM_COLORS");
- DiagramColors colors = DiagramColors.parse(colorSpec != null ?
colorSpec : theme);
+ DiagramColors colors = !"text".equals(theme) ?
DiagramColors.parse(colorSpec != null ? colorSpec : theme) : null;
Path outputFile;
int exit = 0;
@@ -193,6 +193,13 @@ public class CamelRouteDiagramAction extends
ActionBaseCommand {
RouteDiagramRenderer renderer = new RouteDiagramRenderer(
engine.getNodeWidth(), fontSize *
RouteDiagramLayoutEngine.SCALE, engine.getNodeTextPadding());
+ if ("text".equals(theme)) {
+ for (String line : renderer.printTextDiagram(routes,
labelMode)) {
+ printer().println(line);
+ }
+ return 0;
+ }
+
List<LayoutRoute> layoutRoutes = new ArrayList<>();
int currentY = RouteDiagramLayoutEngine.PADDING;
for (RouteInfo route : routes) {
@@ -242,7 +249,7 @@ public class CamelRouteDiagramAction extends
ActionBaseCommand {
} catch (IOException | UnsupportedOperationException e) {
printer().println("Failed to display diagram in
terminal: " + e.getMessage());
printer().println("Falling back to text diagram.");
- for (String line : renderer.printTextDiagram(routes)) {
+ for (String line : renderer.printTextDiagram(routes,
labelMode)) {
printer().println(line);
}
}