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

   Third part of 
[CAMEL-25400](https://issues.apache.org/jira/browse/CAMEL-25400) (tech debt 
cleanup of the CLI, follow-up of 
[CAMEL-25388](https://issues.apache.org/jira/browse/CAMEL-25388)): the 
embedding blockers of the Camel CLI, for the tools that run several commands in 
one JVM (`camel ask`'s `cli_exec`, the AI panel of the monitor, `camel shell`).
   
   ### New command instances for each run
   - `CliRunner` reused the command tree of the CLI, so a field of a command 
that is not an option (state such as the colors and widths of `camel log`, or a 
pid) kept the value of the run before. `CamelJBangMain.newCommandLine()` builds 
a new tree for each run: the commands of the CLI, and the commands of the 
plugins the CLI has already loaded (`PluginHelper` tells the main which plugins 
it added), with the error handling and the user configuration. A new tree takes 
about 15 ms (the classes are loaded once, when the CLI starts).
   
   ### Logging per command
   - log4j was configured once per JVM (`INIT_DONE`): a later command that logs 
otherwise, such as `camel export` to `~/.camel/camel-export.log`, only got its 
level, and logged to the console of the first command (into the output of 
`cli_exec`, or onto the screen of the monitor).
   - `CliRunner` and `camel shell` mark each command they run 
(`RuntimeUtil.newCommand()`), and the first logging configuration of the 
command is then applied (`Configurator.reconfigure`). A command run on its own, 
and the second configuration of a command (the run inside an export), behave as 
before.
   
   ### One catalog loader
   - `camel doc` and the catalog listings had the same method to load the 
catalog of their runtime (Spring Boot, the Quarkus platform, or Camel); there 
is one now.
   
   ### Not in this PR (stays on the JIRA)
   - The duplicates in the run and export commands (`doExport`, the Maven 
invocation) and the shared `.camel-jbang` work directory: they go with the 
run/export split (CAMEL-24724 and others).
   
   ### Tests
   - `CliRunnerTest`: a command that counts its runs in a field counts 1 on 
every run (2 before).
   - `RuntimeUtilLoggingTest`: a command run on its own keeps its first 
configuration; the next command of a CLI that runs several gets the export 
configuration (its log file only), and the one after it the console again.
   - `AiCliCommandExecutorTest` adds its test command in `postAddCommands`, the 
way the launcher adds its plugins, since a command no longer runs on the tree 
the test put in the static field.
   - `mvn test` of camel-jbang-core (2189 tests) and camel-jbang-plugin-tui 
(2160 tests): all pass; camel-jbang-plugin-kubernetes compiles.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01DDRLJAyf8cDXSg8iX785My
   


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