Skip to content

chore: Fix commands using System.console() to work inside camel shell#23479

Open
gnodet wants to merge 1 commit into
apache:mainfrom
gnodet:fix/shell-subcommand-terminal
Open

chore: Fix commands using System.console() to work inside camel shell#23479
gnodet wants to merge 1 commit into
apache:mainfrom
gnodet:fix/shell-subcommand-terminal

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 22, 2026

Summary

Inside the JLine shell (camel shell), System.console() returns null, causing subcommands that read interactive input to silently fail. For example, debug prints nothing because its input-reading thread NPEs on System.console().readLine() in a background thread.

This PR:

  • Moves the active terminal reference to EnvironmentHelper (in core.common) so all commands can detect and reuse the shell's JLine terminal for input
  • Updates isColorEnabled() and isInteractiveTerminal() to check for the active terminal
  • Adds a readLine() helper that uses the terminal when inside the shell, falling back to System.console()
  • Fixes all commands that used System.console() directly:
    • Debug — user input (step, quit, etc.) now works inside shell
    • InfraRun — "press ENTER to stop" now works inside shell
    • Init — interactive template picker now works inside shell
    • CommandHelper.ReadConsoleTask — watch-mode "press enter to stop" now works inside shell
    • CommandHelper.confirmOperation — interactive confirmation now works inside shell

Test plan

  • camel shell then debug hello.yaml — verify step/quit commands work
  • camel shell then init — verify interactive template picker appears
  • camel shell then infra run kafka — verify "press ENTER to stop" works
  • camel debug hello.yaml (outside shell) — verify still works as before
  • camel init (outside shell) — verify interactive picker still works
  • Build: mvn install -B -pl dsl/camel-jbang/camel-jbang-core -DskipTests

Claude Code on behalf of Guillaume Nodet

Inside the JLine shell, System.console() returns null, causing
subcommands that read interactive input to silently fail. This moves
the active terminal reference to EnvironmentHelper so all commands
can detect and use the shell's terminal for input/output.

Commands fixed:
- debug: user input (step, quit) now works inside shell
- infra run: "press ENTER to stop" now works inside shell
- init: interactive template picker now works inside shell
- watch commands: "press enter" to stop now works inside shell
- confirmOperation: interactive confirmation now works inside shell

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet requested a review from davsclaus May 22, 2026 13:01
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions Bot added the dsl label May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-core

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 1 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (6 modules)
  • Camel :: JBang :: Core
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container

⚙️ View full build and test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant