feat: replace picocli with aesh for CLI parsing#2453
feat: replace picocli with aesh for CLI parsing#2453stalep wants to merge 1 commit intojbangdev:mainfrom
Conversation
| BaseCommand cmd = ((BaseCommand) usrobj); | ||
| cmd.realOut = System.out; // Reset the output stream to the original, just for testing | ||
| try { | ||
| BaseCommand cmd = JBang.parseCommand(args); |
There was a problem hiding this comment.
what is this code actually doing ? first parse command and then an exception occurs and it then runs the actual command?
...remind me why ? :)
There was a problem hiding this comment.
parseCommand() gives us direct access to the command instance so we can call doCall() directly and capture the return value — this is what most unit tests need (inspect fields, check exit codes, etc.).
But parseCommand() uses a simplified parsing path that doesn't handle all edge cases (e.g., help requests, parse errors with usage output). When it fails with a CommandLineParserException, we fall back to JBang.execute() which runs through the full aesh runtime and handles those cases properly with correct exit codes and error messages.
In short: fast path for normal commands, fallback to full runtime for error/help scenarios.
Migrate jbang's CLI framework from picocli to aesh, leveraging aesh's compile-time annotation processor to eliminate runtime reflection and improve startup performance. Key changes: - Replace all picocli annotations (@command, @option, @parameters) with aesh equivalents (@CommandDefinition, @GroupCommandDefinition, @option, @argument, @arguments, @OptionList, @OptionGroup, @mixin) - Convert Callable<Integer> commands to Command<CommandInvocation> with CommandResult return type - Port custom type converters, parameter consumers, and preprocessors to aesh Converter and OptionParser interfaces - Implement external plugin command discovery in help output - Add default value provider using aesh's post-parse processing - Wire mutual exclusion validation via aesh's exclusiveWith - Restore version checking, dynamic completion, option aliases, negatable options, and grouped help sections - Regenerate native-image configuration for aesh - Update tests for aesh CLI parsing Performance (vs picocli, median): - Native image: 6ms vs 33ms (5.5x faster) for single commands - JDK 25: 109ms vs 228ms (2.1x faster) - JDK 11: 149ms vs 269ms (1.8x faster) Picks up fixes for inherited option propagation (jbangdev#421) and @OptionGroup keys without values (jbangdev#422).
b6f51c7 to
ad9ecbe
Compare
Migrate jbang's CLI framework from picocli to aesh, leveraging aesh's compile-time annotation processor to eliminate runtime reflection and improve startup performance.
Key changes:
Performance (vs picocli, median):