davsclaus opened a new pull request, #29966: URL: https://github.com/apache/camel/pull/29966
The config part of item 4 of [CAMEL-26931](https://issues.apache.org/jira/browse/CAMEL-26931); the version part is #29945. It came after #29917 (the local configuration is laid over the global one), which changed `CommandLineHelper` too. ## Problem ``` $ camel config set runtime=springboot # exit 0, stored $ camel catalog component ERROR: DefaultValueProvider failed for option runtime # exit 2, every command with --runtime Usage: camel catalog component [-h] [--camel-version=<camel-version>] ... $ camel config unset nope # exit 0, while camel config get nope exits 3 ``` The message of aesh names neither the file, the key nor the value, and the user may not even know that the value comes from the configuration. ## Change - The default value provider checks a value of the user configuration with the converter of the option before it gives it. A value the option does not take fails with exit code 2 and says what to do; the parse error handler prints a `CliException` found in the cause chain of a parse error with its own message and exit code: ``` ERROR: Invalid value in /home/me/.camel-cli.properties: runtime=springboot (Unsupported runtime springboot). Change it with camel config set runtime=<value>, or remove it with camel config unset runtime ``` It names the local `camel-cli.properties` when the key is from there. - `camel config set` checks the value against the options the key is the default of (`<option>` for every command with it, `camel.<command path>.<option>` for one), on a full command line: the command line of a run has only the command it runs. A value one of them does not take exits 2 and is not stored. A key that no command of the CLI has is stored with a warning, as a plugin command may use it. It takes about 300 ms. ``` $ camel config set runtime=springboot ERROR: Invalid value runtime=springboot: --runtime of camel catalog component does not take it (Unsupported runtime springboot) $ camel config set max-seconds=abc ERROR: Invalid value max-seconds=abc: --max-seconds of camel debug does not take it (Invalid integer value: 'abc') $ camel config set nope=1 Warning: no command of the CLI has the option nope; the value is stored, but only a command of a plugin can use it ``` - `camel config unset` of a key that is not set exits with 3, "nope key not found", as `camel config get` does, and leaves the file as it was. A converter that needs more than the value (an aesh context) is left to the parser, so a check never fails a value the parser takes. Upgrade guide entry added. ## Tests - `ConfigValueErrorsTest` (new), on the full command line: `runtime=springboot` in the configuration fails `camel catalog component` with exit 2 and the file, key and value; `config set runtime=springboot` exits 2 and stores nothing, `runtime=spring-boot` is stored; `config set nope=1` is stored with the warning. - `ConfigUnsetTest.shouldHandleMissingKeyToUnset` pinned exit 0 and no output for a key that is not set; it now expects exit 3 and "foo key not found", with the file unchanged. - End to end with the launcher built from this branch, as above. - camel-jbang-core: 3069 + 267 pass (`DependencyUpdateTest` flaked once and passed on the rerun). _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
