davsclaus opened a new pull request, #27961: URL: https://github.com/apache/camel/pull/27961
Second 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 boilerplate the listings copied from each other. ### One sort for the listings - 48 commands had their own copy of `sortRow` (parse `--sort`, a `-` in front reverses, a `switch` per key, the same `pid`/`name`/`age` cases in 30 of them). `RowSort` gives each listing its order once, such as `RowSort.<Row> integration(r -> r.pid, r -> r.name, r -> r.uptime).number("total", r -> r.total)`. - A row without the value of the key comes first (`name` compared without a null check, for example). - An unknown key, such as `camel ps --sort=nmae`, exits `2` and lists the keys of the listing; it left the rows unsorted. - The top commands (`camel top route`, `processor`, `group`) add the slowest first to the order of their status command, through an `order()` method. - `camel version list` and the catalog listings use it too; `camel top source` has no `--sort` and keeps its order (the slowest first). - Two keys the help offered did nothing: `camel get bean --sort=type` sorts by type now, and `camel get transformer` no longer offers `total` (transformers have no total). ### One copy of a row - `CopyableRow` replaces the 18 copies of `Row.copy()` (a `clone()` with the same try/catch), used to make the rows of the routes, consumers or errors of an integration from its row. ### One format - `ListingFormat` replaces the copies of the short endpoint URI (5), since last (4), delta (4) and load (3) helpers, and the slowest-first order of the top commands (3). ### Docs - 4.24 upgrade guide: "an unknown sort key is a usage error". ### Tests - `RowSortTest`: by pid as a number, by name ignoring case, by age, reversed, a missing value first, an alias, no sort, an unknown key (exit 2). - `ListingFormatTest`: short URI, since last, delta, load, slowest first. - `SortOptionsTest`: walks the commands, and checks that the default and the completion values of every `--sort` are keys of the order of its command (it found `camel cmd stub --sort=name`, the default, missing after the conversion, and the two keys above). - `ListProcessTest`: `camel ps --sort=nmae` exits 2; `CatalogKameletTest` sorts with the order of the command, and its unknown key is a usage error. - `mvn test` of camel-jbang-core and camel-jbang-plugin-tui: all tests 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]
