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

   [CAMEL-27055](https://issues.apache.org/jira/browse/CAMEL-27055)
   
   **Stacked on #30201** (CAMEL-27048, `camel cmd` creates only its own 
command): its base is that branch, and the diff here is only this change. 
Retarget to `main` once #30201 is merged.
   
   `camel get route`, `camel cmd reset-stats` and the other sub-commands of a 
command with many (get and cmd have about 40 each) cost 25-30 ms more than 
`camel ps`. The CLI created every sub-command of the group (loading their 
classes: 14 ms with the CDS archive of camel.sh, 36 ms without), and aesh read 
the annotations of each of them, while the command line runs one.
   
   ### Changes
   
   - **`CommandTree` gives aesh only the sub-command that the command line 
names** (`camel get route`: only `route`), at every level. With no arguments, 
an option such as `--help`, or a name that is not a sub-command (aesh then 
suggests the sub-commands: `camel get rout` still says "Did you mean: route?"), 
it gives all of them, as before. Completion and `parser()` always get all of 
them.
   - **`CommandTree.lazy(factory)`**: a tree whose command is created when it 
is first needed (when it runs, when aesh lists it, or on `getCommand()`), and 
is registered for `CommandTree.of` then. `CamelJBangMain` adds the 117 
sub-commands of its groups (get, cmd, catalog, config, infra, ...) this way; 
the top-level commands were already created only when named (CAMEL-26428).
   
   ### Measured
   
   JDK 25, macOS (Apple M4 Pro), through `camel.sh` (with its CDS archive), no 
integration running, median of 15 runs. CPU time (user + system) of the 
process, with the wall time in brackets; the machine was busy, CPU time is the 
steadier number.
   
   | command | main | #30201 | this PR |
   |---|---|---|---|
   | `camel ps` | 220 ms (134 ms) | 218 ms (132 ms) | 217 ms (133 ms) |
   | `camel get route` | 299 ms (163 ms) | 289 ms (158 ms) | 239 ms (140 ms) |
   | `camel get health` | 304 ms (166 ms) | 300 ms (164 ms) | 239 ms (141 ms) |
   | `camel cmd reset-stats` | 618 ms (257 ms) | 296 ms (162 ms) | 234 ms (138 
ms) |
   | `camel cmd route-structure` | 631 ms (254 ms) | 293 ms (160 ms) | 236 ms 
(140 ms) |
   
   ### Tests
   
   As a stacked PR, CI runs no "Build and test" here until it is retargeted to 
`main`; these ran locally:
   
   - `CommandTreeLazyTest` (new): a sub-command is created when it runs and its 
sibling is not; `--help` and a name that is not a sub-command create all (with 
the suggestion); a lazy tree has its name without creating the command, and 
registers it when created.
   - camel-jbang-core: 3101 run, 0 failures (one flake: 
`IntegrationLauncherCommandLineTest.anIntegrationInDevModeThatWatchesItsOwnFiles`
 failed once under the full suite and passed on the retry; it does not use the 
command tree, and passed 3 of 3 runs on its own).
   - camel-launcher: 418 run, 0 failures, 47 skipped.
   - Distribution, against main with a running integration: `get --help`, `cmd 
--help`, `catalog --help`, `get route-controller --help`, `get rout` (exit 2, 
suggestion), `cmd reset-stats`, `cmd route-structure`, `get route --json` 
(counters left out) and `config list` give the same output and exit code.
   
   Related: #30199 (CAMEL-27045), #30201 (CAMEL-27048), #30203 (CAMEL-27050).
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


-- 
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