davsclaus opened a new pull request, #28763:
URL: https://github.com/apache/camel/pull/28763

   _Claude Code on behalf of davsclaus_
   
   Fixes [CAMEL-26428](https://issues.apache.org/jira/browse/CAMEL-26428), 
found while measuring the startup of the CLI for 
[CAMEL-23810](https://issues.apache.org/jira/browse/CAMEL-23810). Independent 
of #28762 (CAMEL-26427, the 300 ms in the exit of the JVM); together they take 
`camel version` from about 920 ms to about 340 ms.
   
   The CLI created all its commands on every run: the 143 commands of 
camel-jbang-core, and in the launcher the commands of the 6 embedded plugins. 
That loads their classes and builds the picocli model of each, also for a 
command line that runs one of them, such as `camel version` or `camel ps`. It 
took about 490 ms of a `camel version` of 566 ms (with #28762): about 230 ms 
loading and creating the command classes, about 115 ms the picocli model, and 
about 150 ms the commands of the embedded plugins, mostly the monitor of the 
TUI.
   
   ## Changes
   
   - **`CamelJBangMain` creates only the command that the command line names** 
(with its subcommands). It creates all of them, as before, for:
     - the help (`--help` or `-h` anywhere, or no arguments), which lists the 
plugins that are not installed;
     - a command line that starts with an option (`camel -V`, `camel --verbose 
version`);
     - a command that is not a command of the CLI (the command of a plugin, or 
a typo, for which picocli suggests the commands it knows);
     - the commands that use the other commands or the plugins: `shell` and 
`completion` use all commands, and the plugins (which may add any command) are 
loaded for `run`, `export` and `cmd` (`PluginHelper.shouldDiscoverPlugins`);
     - a new command line (`newCommandLine()`), on which `camel ask`, `camel 
shell` and the monitor run commands.
   - **The launcher adds the commands of its embedded plugins only when the 
command line has all commands** (`CamelJBangMain.hasOnlyCommand`). None of the 
plugins adds to a command of the CLI, and their exporters and run customizers 
come from the plugin configuration, as before.
   - **The source keeps the form that `PrepareCamelJBangCommandsMojo` reads**: 
each command of the CLI is an `if (shouldCreate(only, "name"))` block with the 
same `.addSubcommand(...)` lines as before, so the mojo needs no change (also 
the one of the Apache snapshots, which the native workflows use). The generated 
metadata (143 commands) and the pages of the commands do not change.
   
   ## Measured
   
   On JDK 25 (Apple M4 Pro), with the classes of the launcher on a flat 
classpath, as JBang runs the CLI, median of 5 runs, together with #28762:
   
   | | before (with #28762) | after |
   | --- | --- | --- |
   | `camel version` | 561 ms | 328 ms |
   | `camel ps` | 569 ms | 324 ms |
   | `camel config list` | | 323 ms |
   | `camel --help` (all commands) | 540 ms | 520 ms |
   
   Of the about 325 ms left, about 170 ms is log4j: 
`CamelCommand.configureLoggingOff()` configures log4j for every command (also 
when it logs nothing). That is a follow-up.
   
   ## Tests
   
   - `CamelJBangMainOnlyCommandTest` (new): `camel config list` has only the 
`config` command (with its subcommands); the help (`--help`, no arguments, 
`config --help`) has all commands; a command that is not of the CLI has all 
commands; `shell`, `completion`, `run`, `export`, `cmd` and a command line that 
starts with an option create all commands; a new command line has all commands.
   - 
`SemanticCommandTest.mainRegistersSemanticCommandsAndFormatsParseErrorsAsJson` 
checked, while `camel semantic eval` ran, that the `get` and `cmd` commands 
have no semantic subcommand: it checks that on a new command line now, as the 
command line of `camel semantic` has only that command.
   - camel-jbang-core: 2427 tests. The only failures fail on `main` locally 
too: the 9 tests of the AI tools about the elvis operator of Simple, and 
`CatalogDocJavaExamplesTest`.
   - camel-launcher: 293 tests pass.
   - The plugin tests that add commands (`TestPluginTest`, 
`AiCliCommandExecutorTest`) run commands that are not commands of the CLI, or 
on a new command line, so they have all commands.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_0128ThHB3iQdrvSRLVBGRrdP
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to