Skip to content

fix: Add proper picocli argument completion via AutoComplete#1708

Merged
gnodet merged 1 commit intomasterfrom
fix/picocli-argument-completion
Mar 23, 2026
Merged

fix: Add proper picocli argument completion via AutoComplete#1708
gnodet merged 1 commit intomasterfrom
fix/picocli-argument-completion

Conversation

@gnodet
Copy link
Member

@gnodet gnodet commented Mar 23, 2026

Summary

The PicocliCommandRegistry only completed command and option names using a simple StringsCompleter. This missed:

  • Option values (when provided as separate arguments)
  • Positional parameters with completion candidates
  • Nested subcommand arguments

Changes

  • Command.java: Add completer() default method that returns a single Completer for non-positional completion strategies (e.g., picocli commands where options can appear in any order)
  • DefaultCommandDispatcher.java: Check cmd.completer() first before falling back to the position-based completers() list wrapped in ArgumentCompleter
  • PicocliCommandRegistry.java: Use picocli's AutoComplete.complete() in both compileCompleters() (legacy CommandRegistry path) and PicocliCommand.completer() (new CommandGroup path), which properly handles all completion types

Test plan

  • All 12 picocli tests and 206 shell tests pass
  • Verified with Apache Camel JBang shell REPL — argument completion now works for all picocli commands

The PicocliCommandRegistry only completed command/option names using a
simple StringsCompleter. This missed option values, positional parameters,
completion candidates, and nested subcommand arguments.

Changes:
- Add Command.completer() method for non-positional completion strategies
- DefaultCommandDispatcher checks cmd.completer() before falling back to
  the position-based completers() list
- PicocliCommandRegistry now uses picocli's AutoComplete.complete() which
  properly handles all completion types: options, option values, positional
  parameters with completion candidates, and nested subcommands

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet merged commit 4fdcc8f into master Mar 23, 2026
9 checks passed
@gnodet gnodet deleted the fix/picocli-argument-completion branch March 23, 2026 08:59
gnodet added a commit to apache/camel that referenced this pull request Mar 23, 2026
JLine 4.0.8 includes jline/jline3#1708 which fixes PicocliCommandRegistry
to use picocli's AutoComplete for proper tab completion of options, option
values, positional parameters, and nested subcommands.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit to apache/camel that referenced this pull request Mar 23, 2026
JLine 4.0.8 includes jline/jline3#1708 which fixes PicocliCommandRegistry
to use picocli's AutoComplete for proper tab completion of options, option
values, positional parameters, and nested subcommands.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant